The problem is that if the data returned by your getline function is less than the length of
stemp
, you will get an error. For example, if the line it reads is empty, you will immediately get a problem.
counter=1;
getline(myfile,sline);
iStudent_num++;
while(stemp[counter]==sline[counter])
Try it: put a breakpoint on the getline, and see what it returns each time. Then add a check to ensure there are at least as many characters as you are going to compare against before you enter the loop!