E
entropy123
Hey all,
A newbie, I am working through Kernighan and Ritchie.
I'm having a problem with one of their test programs & MS VS 2003. In
particular the EOF value for VS2003 in winxp is apparently '-1'
However when I enter '-1' as a character in this program the program
(which ought to terminate when EOF is input) will not quit. I need to
hit 'ctrl-c' to exit the program ----> no output...
Thanks for your help,
entropy
Here is the program:
#include <stdio.h>
int main()
{
int c, nl;
nl = 0;
while (( c = getchar() ) != EOF)
if ( c == '\n')
++nl;
printf("%d\n", nl);
}
A newbie, I am working through Kernighan and Ritchie.
I'm having a problem with one of their test programs & MS VS 2003. In
particular the EOF value for VS2003 in winxp is apparently '-1'
However when I enter '-1' as a character in this program the program
(which ought to terminate when EOF is input) will not quit. I need to
hit 'ctrl-c' to exit the program ----> no output...
Thanks for your help,
entropy
Here is the program:
#include <stdio.h>
int main()
{
int c, nl;
nl = 0;
while (( c = getchar() ) != EOF)
if ( c == '\n')
++nl;
printf("%d\n", nl);
}