On 1/30/2011 4:08 PM, John wrote:
> The program is supposed to read lines from the standard input, then each line is printed on the standard output preceded by its line number. The program should have no built-on limit on how long a line it can handle.
>
> So I wrote the following program in C, but I'm not sure that it is doing what it is supposed to do. I verified the source code against the solution in the back of the book and I'm pasting here what the solution in the back of the book is.
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int main(){
>
> int ch;
> int at_beginning = 1;
> int line = 0;
>
> while( (ch==getchar())!= EOF){
You want `=' instead of `==' here. (This may be the first time
I've seen the "equals/assign" mistake in this direction; usually, it's
using `=' where `==' is meant, not the other way around.)
--
Eric Sosman
lid