print on multiple lines?

I can not get the out put file to print on multiple lines, the typical end line commands seem to have no effect on the file created.

ex.
1
2
pds << name << " " << employID << " " << rate << " No Hours worked " << nwln << '\n' << endl;
 


if I print this to the output file in a loop it puts it all on one line.

is there another key word command?
What is pds?
jeckel,
pls explain the structure of UR input & output files so that a solution may be found , TNX.
can you give the whole scripts?
your code should work, but it will put 2 new lines in your output since you have
<< '\n' << endl;

I think it's a personal preference but you might try and change << '\n' to << "\n" or remove it. If you want 2, use << endl << endl;

To test your code, put this infront of your output to make sure they have values.

cout << name << endl;
cout << employID << endl;
cout << rate << endl;
cout << nwln << endl;

Then put in a check to make sure your ofstream file is open.

Last I would change
<< " No Hours worked "
to
<< " Num Hours worked "

No could be misunderstood as Zero.

I'm guessing you didn't open your output file.

1
2
3
ofstream pds;
pds.open ("filename.txt");    // output file
pds << " this is a test";

Topic archived. No new replies allowed.