What's wrong ?



Hello.
I just copied this code from my book with no modification :

#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;

nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}

There is no output, and no completion either. I tried adding a "printf" at
the end of the code, but it doesn't display.

i'm using MinGW developer studio with windows XP home.

Thanks in advance.
Daniel


.



Relevant Pages

  • Re: Whats wrong ?
    ... while (getchar()!= EOF) ... i'm using MinGW developer studio with windows XP home. ... You have to input an end of file character ...
    (comp.lang.c)
  • Re: Whats wrong ?
    ... while (getchar()!= EOF) ... i'm using MinGW developer studio with windows XP home. ... jacob at jacob point remcomp point fr ...
    (comp.lang.c)
  • Re: user input, getchar, and buffer - For C beginners and those with teaching skills...
    ... easy to deal with with little a basic knowledge of getchar and the ... characters are still there in the input buffer and this is, sometimes, ... EOF is in int designed ... so that no valid character can be confused with it. ...
    (comp.lang.c)
  • Re: Obtaining Last Logon Time for Domain User
    ... Subject: Re: Last time each NT account was accessed ... > framework 1.1 to run this tool (you can get it from Windows Update). ... >> goto:EOF ...
    (microsoft.public.windows.server.active_directory)
  • Re: cannot understand the character handling Program
    ... > getchar have been used here. ... The C Standard does not guarantee that this is the right way to specify ... > then it will asuume stdin standard stream attached to the keyboard as ... > 2.as u have asked about EOF ...
    (comp.lang.c)