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

A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a C++ program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.

2 Answers  


What is Destructor in C++?

0 Answers  


How do I make turbo c++ full screen?

0 Answers  


How to allocate memory dynamically for a reference?

0 Answers  


Write a corrected statement in c++ so that the statement will work properly. x + y=z;

2 Answers  






Is c++ primer good for beginners?

0 Answers  


Is set c++?

0 Answers  


reading material is provided 3 books for c++ if u need more do let me know thnx i hve lots of material do let me know if u want it

2 Answers  


What is ios class in c++?

0 Answers  


How is an Abstract Base Class(ABC) related to an "Abstract Data Type" (ADT)

2 Answers  


What is buffering in c++?

0 Answers  


What is the difference between the compiler and the preprocessor?

0 Answers  


Categories