C++ Tutorial 66 Concept Problem

0 Vikram Jayanthi · July 16, 2014
I dont understand a line of code that Bucky writes in tutorial 66.
Code Below:
#include <iostream>
#include <fstream>
using namespace std;


int main()
{
ofstream fobj("players.txt");
cout<<"Enter players ID, Name and account"<<endl;
cout<<"Press Cntrl + Z to quit"<<endl;
int id;
string fname;
string lname;
float money;
fobj<<"ID    "<<"LastName    "<<"FirstName    "<<"Balance"<<endl;
while(cin>>id>>lname>>fname>>money)      //What does this line mean?//
{
fobj <<id<<"    "<<lname<<"    "<<fname<<"    "<<money<<endl;
}
fobj.close();


}
The line of code is while(cin>>id>>lname>>fname>>money)
What does this mean?
Please Reply,
Thanks.

Post a Reply

Replies

Oldest  Newest  Rating
0 Dima Sama · July 20, 2014
Yup kroothusas is correct. The while loop with input (which is cin) as a conditional means that the loop will continue as long as the input is correct. It will only terminate if the user put an incorrect type or the user entered/reach the EOF (End-of-File) which is Ctrl+Z
  • 1

C++

107,113 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator