Hey all,

stuck on abit of a problem. I am outputting afew strings to a text file. However when I check the text file it has been automatically split into 2 lines. Is there anyway to force the output to remain in one line or what is the reason for this to happen. I have outputted similar length lines to text files and have had no issue so its not breeching any text file limits. The code I am using is as follows:

/////	Output congested traffic file to text file	//////

ofstream myfile;
myfile.open ("CMPOutput.txt",ios::app);
myfile << HEAD << arr_time.str() << output_speeda.str() << SPACE << LENGTHa.str() <<
       SPACE1 << lane << REST << FOHb.str() << endl;

The output is a mix of stringstreams and intergers but I dont think this is the issue as I have changed all to string and still have the same issue. Any help would be greatly appreciated. Thanks in advance.


6 Years
Discussion Span
Last Post by colmcy1

You'll have to show us the values of all of the variables you are outputting. One of them must have a new line character. If you can produce a compilable example that writes the 2 line file, we'd be happy to check it out.



Thanks a million Dave,

was not looking forward to scrawling through code this morning. You were correct, I had a:

<< endl;

placed at the end of a definition of a stringstream. Thanks again for your help, obvious issue but youd be suprised how many hours someone like me could bury looking for the a solution :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.