Text file does not create newline


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


instead of this


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

cin >> Gender;
cin >> Age;
cin >> State;

ofstream InfoFile;
InfoFile << Gender << endl << Age << endl << State;
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.

Registered users can post here. Sign in or register to post.