N
Naya
Hello, everyone!!!
Well, I have a situation here. I am trying to read this data from a
file, but the wrong values keep spitting out at me. Here's what I
mean:
Program:
int main()
{
ifstream inFile;
int people;
inFile.open("people.dat");
cout <<"Reading information from the file. \n\n";
inFile >> people;
cout << people <<endl;
inFile >> people;
cout << people << endl;
inFile >> people;
cout << people << endl;
inFile.close();
cout << "\nDone.\n";
getch();
return 0;
}
My output goes like this:
Reading information from the file.
4219055
4754128
4754128
Done.
However, the data that is in the file is as follows:
2000 4000 5000 9000 14000 18000
How can I get this exact output to appear on my output screen?
PLEASE HELP!!
Well, I have a situation here. I am trying to read this data from a
file, but the wrong values keep spitting out at me. Here's what I
mean:
Program:
int main()
{
ifstream inFile;
int people;
inFile.open("people.dat");
cout <<"Reading information from the file. \n\n";
inFile >> people;
cout << people <<endl;
inFile >> people;
cout << people << endl;
inFile >> people;
cout << people << endl;
inFile.close();
cout << "\nDone.\n";
getch();
return 0;
}
My output goes like this:
Reading information from the file.
4219055
4754128
4754128
Done.
However, the data that is in the file is as follows:
2000 4000 5000 9000 14000 18000
How can I get this exact output to appear on my output screen?
PLEASE HELP!!