Hi everyone
I did a counter to get the value from a simple number file, because I used the counter to
now the problem if I had less than 10 lins in that file. it will give result of ( abnormal termination).Code:while ( counter <=10) { value=getline( filename, line); sum+=value; counter++; }
so, I changed it with
but this gives me as well termination error with my orignal file with 10 lines and same error with a file of less than 10 line.Code:ifstream indata(filename) while ( !filename.eof) { value=getline( filename, line); sum+=value; counter++; }
I know eof is not a good thing to terminate and exit the loop. but what else could I use.
so anyidea with example to fix similar error.
thank you all
all the result are wrong



LinkBack URL
About LinkBacks


