Dec 23, 2011 at 2:35am UTC
in xcode, when you use \r i see nothing. what does it do? I know its a carriage return but I dont understand it
Dec 23, 2011 at 4:08pm UTC
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
Dec 23, 2011 at 4:09pm UTC
Dec 23, 2011 at 4:12pm UTC
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?
Dec 23, 2011 at 4:39pm UTC
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:
2 3 4 5 6 7 8 9 10 #include <iostream>
using namespace std;
cout << "Hello world!";
cout << "\rNow";
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
Dec 23, 2011 at 4:40pm UTC
Dec 24, 2011 at 1:19pm UTC
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.