for loop - C++ reading values into an array on XCode -
i can't figure out why following code doesn't output properly. it's supposed read name , grades an entry of array of students. reason, there phantom entries in between real entries, denoted lines in output don't have name preceding numbers.:
fin.open("data.txt"); ( int i=0 ; getline(fin, info[i].name) && (i<size) ; i++){     fin.clear();     fin >> info[i].quiz.gradeone;     fin >> info[i].quiz.gradetwo;     fin >> info[i].quiz.gradethree;     fin.clear();     numb++;     cout << info[i].name << info[i].quiz.gradeone << info[i].quiz.gradetwo           << info[i].quiz.gradethree << endl; } fin.close(); here's data:
jeramy puleo 45 99 101 liz kershaw 55 70 35 sherrill dykes 88 94 100 emmitt auclair 89 94 88 nana bassler 22 55 88 and (wrong) output:
jeramy puleo 45 99 101  0 32767 0 liz kershaw 55 70 35  0 0 0 sherrill dykes 88 94 100  0 0 0 emmitt auclair 89 94 88  0 0 0 nana bassler 22 55 88  
 
Comments
Post a Comment