Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what is the basic functionality of \r? it will produce different results with executing in diff compilers like MinGW and linux?
Posted
Updated 23-Mar-13 7:11am
v2
Comments
Volynsky Alex 23-Mar-13 13:48pm    
http://msdn.microsoft.com/en-us/library/6aw8xdf2%28v=vs.80%29.aspx

Character: Carriage return
ASCII Representation: CR
ASCII Value : 13 or 0x0d
Escape Sequence : \r

Totally agree with the previous answer!

'\r' is the carriage return character.
The following repeats the loop until the user has pressed the Return key.
C++
while(ch!='\r')
{
  ch=getche();
}
 
Share this answer
 
It's not generally a compiler thing, it's an OS interpretation thing.
'\r' is a character called Carriage Return - because in the days of teletypes that is what it did, it moved the carriage (i.e. print head) to the left hand side of the paper.
Different system interpret what it does differently: some move the cursor to the far left, some move it to the left and down a line.

If you can, and you want to be portable, avoid using it directly - declare a constant instead so you cna change it if you need to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900