Text file does not create newline

Hello,

I have this simple code. The resulting text file became output like this

F16Perlis

instead of this

F
16
Perlis

Anyone can help me figure out the problem? I already use endl many times but still get the same result.

<code>
cin >> Gender;
cin >> Age;
cin >> State;

ofstream InfoFile;
InfoFile.open("test.txt");
InfoFile << Gender << endl << Age << endl << State;
<code>
Use std::endl to end a line.
Can you post your whole program?

And when you use code tags (thanks for trying), use square brackets for your opening tag and square brackets with a forward slash for your closing tag. Or, highlight your code and click the "<>" Format button. For some reason the Format button doesn't work on the initial post, but you can edit your post and add the format after the post is up.

Use the Preview button to see if you got the code tags to work properly before hitting submit.

Topic archived. No new replies allowed.