Hi,
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;
Outline=line;
Outline.resize(Outline.length()+20);
ofstream Outfile ("result.txt", ios::out | ios::app );
if(Outfile.is_open())
{
Outline.insert(20,"10");
Outline.insert(25,"15");
Outline.insert(30,"16");
Outfile<<Outline<<endl;
}
Outfile.close();
}