in Programming in C retagged by
387 views
0 votes
0 votes
if i write $\text{printf("norma\bl")}$,then output is $norml$,but when i write $\text{printf("normal\b")}$,then output is $normal$..why

can anyone explain concept of $\text{\b}$
in Programming in C retagged by
by
387 views

2 Answers

1 vote
1 vote
first of all its compiler dependent

the concept of '' \b' can be explained from below example

printf("hello\b");

output will be hell as \b(back space) is used to escape one character

for your question printf("norma\bl")

output will be norml as explained above

for printf("normal\b") it will be norma
0 votes
0 votes
The output of the /b escape sequence depends on compiler to compiler.

1. Various possible outputs are:Non-destructive backspace : Here, a “\b” just makes the cursor shift backwards , without erasing any data and replacing the current character encountered with the new entered one.
2. The conventional backspace : Here, a “\b” means the normal backspace we use through our keyboards..

Example:
char name1[]=”sachin”;
char name2[]=”al”;
printf(“%s\b\b\b%s”, name1,name2);
Here, the output as per situation 1 would be

sacaln

, and as per situation 2 would be

sacal.

Related questions