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
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.
We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.
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.
Thor's self help tip:
Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.
OS: Windows XP
Compiler: MSVC
yes use endl, very wise thing
if you dont believe us about the buffer try using '\n' right before a getch() hehe.
-LC
Asking the right question is sometimes more important than knowing the answer.
Please read the FAQ
C Reference Card (A MUST!)
Pointers and Memory
The Essentials
CString lib