This program is designed to calculate your bodyfat percentage using a method used by the navy. I want to enter the info, have it print the results to a file. When I reopen the program and re enter new info, for it to append on a NEW LINE, not the SAME LINE.
It does this "25.8 25.8. 25.8" (one line)
I want it like this:
25.8
25.8
25.8
1 2 3 4 5 6 7 8 9 10 11 12 13
// multiply measurements by 2.54 to convert inches to centimeters
bodyfat = 495 / ( 1.0324 - .19077 * ( log10( ( waist * 2.54 ) - ( neck * 2.54 ) ) ) + .15456
* ( log10( height * 2.54 ) ) ) - 450;
ofstream fout;
fout.open ("bodyfat.txt", ios::out | ios::app | ios::binary);
cout << setprecision(2) << fixed << bodyfat << endl;
fout << endl; // this doesn't work for a new line
fout << setprecision(2) << fixed << bodyfat << endl;
fout.close();
cin.ignore();
Since endl is failing for you, I am thinking you are using Windows and your compiler has a version of endl that throws only a LF character into the file, but in Windows you need CRLF.