i tested it out and cant figure out \r

in xcode, when you use \r i see nothing. what does it do? I know its a carriage return but I dont understand it
The \r is supposed to output a new line. Older versions of OSX with XCode did not run all the escape codes. Some behaved awkwardly. But the newest OSX is supposed to have fixed the \r option.

Remember, XCode console is not a Terminal, so it was not meant to be run like one using escape codes, which is what \n and \r and \b and others like it is.
Last edited on
yeah i know they are escape codes but i did (in cout) \r with the newest xcode, and i put it between text and Text but there was just a space. is this a bug?
As far as I know \r is carriage return and by that it means it return to the start of your line. Not to the next line like \n.

So the next piece of code:
1
2
3
4
5
6
7
8
9
10
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!";
    cout << "\rNow";
    return 0;
}


outputs:
Nowlo world!


I don't know anything about xcode so can't help there. But it should work on every console. It's basic I/O.
Last edited on
Yea in XCode the escape codes did not work. Not all of them at least. Couple did. And so they were supposed to fix this with the newest OSX Lion version. Is this the Operating System your on ? If not, that's why it doesn't work.
Topic archived. No new replies allowed.