views:

16

answers:

1

Hello all,

I have a problem using a carriage return to rewind to the beginning of a line within XCode.

This small example:

std::cout << "will not see this\rwill see this" << std::flush;
std::cout << std::endl; // all done

compiled in XCode results in:

will not see this

will see this

whereas, when I compile it in the terminal using G++ I get:

will see thisthis

How can I make XCode show the latter (and expected) behavior ?

cheers Daniel

+1  A: 

Are you running the Xcode-compiled application in the Terminal or are you reading the output from the debug Console? They are two different outputs and may have different formatting. Xcode uses gcc under the hood so I am surprised at the results you are seeing here. In addition this question (Which you seem to have found) gave me the results I wanted by using \r to return to the beginning of a line.

fbrereto
You are right the problem only occurs in the IDE's integrated console but not when the app is run in the terminal. Not sure why I didn't try it myself. Thanks, though.
luuke