When outputting variables to a textfile, how could I make it skip a line after each?

Dec 11, 2014 at 7:58am
Hello, my question is as titled pretty much.



1
2
3
4
5
6
7
8
9
10
//sameple code
while{

switch (char1)
	{
	case 'A':
 output(	cout, result, ordervector);					
 orderUP << ordervector[result].id2[0] << ordervector[result].id2[1] << " , ";
 orderUP << ordervector[result].burger2 << " , " << ordervector[result].price2    << endl;
	break;


Here the switch function is inside a while function. I tried ' << "\n"; but dind't work either.
Dec 11, 2014 at 10:43am
how could I make it skip a line after each?
[...]
I tried ' << "\n"; but dind't work either.
What do you mean "didn't work"? If you remove it it gives you same result as if it was here?

To skip a line you need: print linefeed symbol to move to the next line; prine linefeed symbol again to move to the next line and leave one empty.
So you need to write "\n\n" instead of endl.

And one more: do not use endl. Prefer '\n' instead. Use it only when you need flushing the buffer (which is almost never). Such buffer flushing can seriously slow down your program.
Topic archived. No new replies allowed.