Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++
what is the basic functionality of \r? it will produce different results with executing in diff compilers like MinGW and linux?
Posted 23-Mar-13 7:57am
Edited 23-Mar-13 8:11am
Volynsky Alex at 23-Mar-13 13:48pm
Character: Carriage return
ASCII Representation: CR
ASCII Value : 13 or 0x0d
Escape Sequence : \r
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310

Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100