What does '\r' and '\b' mean? Please explain with example.

Answers were Sorted based on User's Feedback



What does '\r' and '\b' mean? Please explain with example. ..

Answer / ankita

\r is known as carriage return
e.g printf("ABC\rDE");
ABC.
then becoz of \r cursor comes back to the 1st char i.e here
A after that DE is there then finally it print
DEC with cursor on C.
\b is known as back literal
e.g. printf("ABC\bDE");
then ABC then finally ABDE will get printed.

Is This Answer Correct ?    63 Yes 27 No

What does '\r' and '\b' mean? Please explain with example. ..

Answer / brite

Even you are wrong Siva.
printf("ABC\rDE") will print DEC not DE.

Is This Answer Correct ?    32 Yes 16 No

What does '\r' and '\b' mean? Please explain with example. ..

Answer / siva

above two answers are wrong.
i tested the following is the correct answer


\r is known as carriage return
e.g printf("ABC\rDE");
DE will get printed.
\b is known as back literal
e.g. printf("ABC\bDE");
ABDE will get printed.

Is This Answer Correct ?    31 Yes 21 No

What does '\r' and '\b' mean? Please explain with example. ..

Answer / subh

Depends on terminal configuration

http://stackoverflow.com/questions/17236242/usage-of-b-and-r-in-c

Is This Answer Correct ?    1 Yes 2 No

What does '\r' and '\b' mean? Please explain with example. ..

Answer / mahboob ur rahman

System.out.print("mahboob\rkhan");
output:
mahboob
it will just priint mahboob

Is This Answer Correct ?    1 Yes 13 No

What does '\r' and '\b' mean? Please explain with example. ..

Answer / yogita

\r is used for carriage return and \b is used for computer
baep

Is This Answer Correct ?    18 Yes 32 No

What does '\r' and '\b' mean? Please explain with example. ..

Answer / v

printf("ABC\bDE");


It prints only "DE", because the printed ABC will be removed
by '\b'

Is This Answer Correct ?    11 Yes 28 No

Post New Answer

More C++ General Interview Questions

There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?

1 Answers   TCS,


Write about a nested class and mention its use?

0 Answers  


What does override mean in c++?

0 Answers  


Explain what happens when a pointer is deleted twice?

0 Answers  


What is the difference between #import and #include?

0 Answers  






Do class declarations end with a semicolon?

0 Answers  


Why for local variables the memory required to hold the variable is allocated from the program stack and for new its allocated from the heap?

1 Answers  


Is it possible for the objects to read and write themselves?

0 Answers  


What is the full form of india?

0 Answers  


write the prime no program in c++?

16 Answers  


What is the difference between reference and pointer?

0 Answers  


Explain how to initialize a const data member.

0 Answers  


Categories