[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Can't read stdin.



On Fri, Jul 19, 2002 at 07:36:37AM -0400, James Hughes wrote:
> Then I compiled the following program, straight from page 17
> of K&R's The C Programming Language:
> 
> int main(void)
> {
>    int c; 
>    while ( (c = getchar()) != EOF) 
>       printf ("You typed: %c\n", c);
> 
> }

Not at all.  I added the following lines to your program:

    #include <stdio.h>
    #include <stdlib.h>

And after your while loop, I added
    
    return EXIT_SUCCESS;

Just to be pedantic.  Anyway, here's the output:

    chewie@chef:~/src [509]$ a.out
    blah
    You typed: b
    You typed: l
    You typed: a
    You typed: h
    You typed:

    blee
    You typed: b
    You typed: l
    You typed: e
    You typed: e
    You typed:

I compiled this on both potato and woody w/gcc versions 2.95.2 and 2.95.4.  Did
you forget the include headers?

-- 
Chad Walstrom <chewie@wookimus.net>                 | a.k.a. ^chewie
http://www.wookimus.net/                            | s.k.a. gunnarr


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: