Click here to Skip to main content
11,935,012 members (53,063 online)
Rate this:
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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2015
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