Text output not in rows

Hi guys,
I'm trying to print a table of data to a text file, but all the data is printing on the same line, even tho I've used endl.



while(abs(fun(x))> acc && abs(x2-x3)>acc){
x1=x-(fun(x)/dfun(x));


xm=(x2+x3)*0.5;
z= fun(x2)*fun(xm);

cout<< setprecision(5); // These two lines limit the output to 5 s.f.
outs<< setprecision(5);

cout <<setw(10)<< x<<"\t "<<(x1-x) << setw(10)<< xm << setw(15) <<(x2-xm)<<setw(10)<<i<< endl;
outs<< x<<"\t "<< (x1-x) << "\t"<< "\t "<< xm << "\t "<< (x2-xm)<<"\t "<<i<< endl;
if (z>0){x2=xm;}
if (z<0){x3=xm;}
x=x1;
i++;

}

thanks for the help
Last edited on
What text editor are you using? Windows Notepad is not very good because it is only familiar with one type of newline, which may not be the same as the type of newline you are emitting. I recommend using Notepad++ instead.
I'm using Windows Notepad unfortunately and I'm on my university's computer so i can't download Notepad++. Is there anything you can suggest to correct it for Notepad?
There is a workaround here: http://superuser.com/a/362092/219815

Alternatively you could modify your program to output "\r\n" instead of std::endl, but I don't recommend that.
Thanks alot that was very useful
Topic archived. No new replies allowed.