Fstream problem

Sep 25, 2011 at 11:36am
When I am outputting to a file, such as

1
2
3
4
5
6
7
8
9
10
ofstream output;
output.open( "myfile.out", ios::out );
	if( !output.is_open() )
	{
		cerr << "Failed to open file" << endl;
		return 1;
	}

int example = 30
output << "This line with " << example << " should be on one line" << endl;


but in myfile.out it looks like this:

1
2
This line with 30
 should be on one line


How do you get it to print like it would if just printing to standard output?
Sep 25, 2011 at 11:53am
Not sure why this isn't working for you. I added a ; to the end of line 9 and it works fine for me.
Sep 25, 2011 at 11:55am
I just tried the code (missing ; after int example = 30) in Visual Studio 2010 and it printed everything on one line.
Topic archived. No new replies allowed.