|
|
|
|
|
|
data in file(in one column): 2 6 8 9 10... value of counter : 1 2 3 4 5 6 7 8 9... |
value of counter value of the file 1 2 2 6 3 8 4 9 6 10 |
|
|
|
|
while (!eof)
thing is a hangover from C, where files were read 1 char at a time, and there was an ungetc function as well.while ((c = getchar()) != EOF)
Counter values should be= 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 |
2 4 6 7 8 10 13 14 15 |
|
|
value of counter value of the file 1 2 2 4 3 6 4 8 6 10 7 11 8 12 9 13 10 14 11 15 |
|
|
Every time I see "while (!eof)" I die a little inside... |
Would you please explain why this should be avoided? |
counter file action I or II 1 1 action I 2 2 action I 3 3 action I 4 action II 5 action II 6 6 action I 7 7 action I 8 action II 9 action II 10 action II 11 action II 12 12 action I |
|
|