io_x
2/12/2011 2:36:00 PM
"John" <> ha scritto nel messaggio
news:fbf56c22-2583-4a79-b5a3-714cf2061c4d@glegroupsg2000goo.googlegroups.com...
>
> int main(){
>
> int ch;
> int at_beginning = 1;
> int line = 0;
>
> while( (ch==getchar())!= EOF){
Errors "secondo me":
0) yes these above "==" should be "=" else
the program could never stop
1) done some test; it loose the last line in the ridirect
output (if there are at end \n\n) print one line less
of line there are in the file
2) it has to print in stdout at End of input: "\n"
>
> if(at_beginning == 1){
>
> at_beginning = 0;
> line+=1;
> printf("%d ", line);
>
> }
>
> putchar(ch);
>
> if(ch == '\n')
> at_beginning = 1;
> }
> return EXIT_SUCCESS;
> }