Here is an incomplete fraction of a program I am writing. To summarize, the program takes info from an input file ( a name and ID then a series of numbers) does some math and then prints the answers in an output file. Right now the program prints the name and the ID, and then it prints the numbers over and over and over and over. I would like it to move to the next line, print the name and ID and repeat until the file is over
Professor says that I should be using getline, but that doesnt make any sense to me
do
{
infile >> name >> Id;
cout<< name << Id << std::endl;
hworkgrade = CalHworkGrade(grade1, infile);
printRecord(name, Id, outfile);
}
while(!infile.eof());
input:
Morgan 12388671 100 100 100 John 67894 100 100 100
output:
Vagts,Morgan 100100 100100 100100 100100 100100 (300,000 more times)
Update:
do
{
while (getline (infile, line))
{
istringstream iss(line);
iss >> name >> Id;
cout<< name << Id;
hworkgrade = CalHworkGrade(grade1, infile);
printRecord(name, Id, outfile);
}
}
while(!infile.eof());