information stacking together creating a text file.
hi when i try to run the loop it should create a new line but it doesn't. help!!
input >> 1 test 55.32 [enter]
2 test2 99.99 [enter]
3 test3 88 [enter]
file output>> 1 test 55.322 test 99.993 test3 88
i did add <<endl; :(
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
//Writing Custom File Structures
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream theFile("players.txt");
cout << "Enter the players ID, Name, Money" <<endl;
cout << "Enter Ctrl+Z to quit\n" <<endl;
int idNumber;
string name;
double money;
while(cin >> idNumber >> name >> money){
theFile << idNumber <<' '<< name << ' ' << money << endl;
}
return 0;
}
|
There will be a new line in the output file. What make you think there isn't?
wait what.. my notepad is broken!
if i copy all from the bloody thing and past on here.
1 test1 33.22
2 test2 56
3 test3 8
but if i open the file in notepad it looks
1 test1 33.222 test2 563 test3 8
sorry!
computer problems
grrrr!
Topic archived. No new replies allowed.