I would like to output 3 lines, each on their own line, for example:
Heading
1 | 2 | 3
x y z
Does anyone know anyway to force a line break?
Thanks, Torsin
Printable View
I would like to output 3 lines, each on their own line, for example:
Heading
1 | 2 | 3
x y z
Does anyone know anyway to force a line break?
Thanks, Torsin
you can do
orCode:cout<<"blah"<<endl;
both should workCode:cout<<"blah\n";
I would recommend the one with endl, becouse it also flushes the output buffer I think.
Wow! Impressed with quick reply, thanks :)
to clarify what Aidman said, '\n' will add a new line to the buffer, but in C++, the contents of the stream aren't output until the buffer is full, so you might get strange results (something else may print in the middle, I had this happen for the first time recently).
endl flushes the buffer, which causes it to be output to the screen.
yes use endl, very wise thing
if you dont believe us about the buffer try using '\n' right before a getch() hehe.
-LC