retagged by
380 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}$
retagged by

2 Answers

1 votes
1 votes
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

2 votes
2 votes
0 answers
1
Aradhana Singh asked Aug 26, 2016
1,602 views
how many characters does an escape sequence (\On , \Hn ,\n ,\f) in C++ consumea)1 b)3 c)2 d)none
1 votes
1 votes
1 answer
2
admin asked Oct 15, 2015
647 views
How tokens are assigned for a string having escape sequence in C lexical phaseEg..printf ("this\" is a string\"");and what forprintf ("this is""a string");