C++ code explanation

//Writing Custom File Structures
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ofstream Traits("Players.txt");

cout << "ENTER PLAYER ID, NAME, MONEY\n";
cout << "press CTRL+Z to quit\n";
int idNumber;
string name;
double money;

while(cin >> idNumber >> name >> money){
Traits << idNumber << " " << name << " " << " " << money << endl;
}
}




in this code i coudnt quite understand the while loop

while(cin >> idNumber >> name >> money){
Traits << idNumber << " " << name << " " << " " << money << endl;



can someone please explain this....
cin overloads operator >> ( http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/ ). It returns number of characters inputed ( http://www.cplusplus.com/reference/istream/istream/gcount/ ).

Because cin will always return value > 0 (pressing enter is 1 since '\0') user must pres ctrl+z.
Last edited on
what does the while loop mean?
why would it stop or keep going on?
I'm sure even the most rudimentary of C++ tutorial sources will explain what a while loop is and how they work.
Topic archived. No new replies allowed.