I am trying to write strings to a file line by line and trying to format the output so that the alignment is proper.
output should be
it should appear in the output file as

david      10   15   16 
sam        11   15   16   

but appears as david 10 15 16 sam 11 15 16 there is no new line all output is on the same line despite using endl.
my code is attached below..pls tell me thats wrong, or if some other method exists to implement the above as i want the numbers to be aligned column wise.
Note: all parameters are strings like david ,10,15,16 will all be seperate strings

bool WriteOutputFile(string line)
string Outline;
int linelength;


    ofstream Outfile ("result.txt", ios::out | ios::app );


Recommended Answers

All 3 Replies

Did u try writing the '\n' char instead of 'endl'?

thanks jonsca

it worked like a charm using setw is so much easier...and i got the solution of the new line issue seems cygwin recognises /r as new line command!

thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.