D
Dave Casserly
Below is the code ive written just to count the characters typed in. I
assumed EOF is -1, so if i type -1 and then press enter shouldnt the
program end? It orks if i put something like 'q' in the while loop to
end the loop.
what is up?
<code>
#include <stdio.h>
void main() {
long nc;
nc = 0;
while (getchar() != 'EOF') {
++nc;
}
printf("%ld\n", nc);
}
</code>
thanks
Dave
assumed EOF is -1, so if i type -1 and then press enter shouldnt the
program end? It orks if i put something like 'q' in the while loop to
end the loop.
what is up?
<code>
#include <stdio.h>
void main() {
long nc;
nc = 0;
while (getchar() != 'EOF') {
++nc;
}
printf("%ld\n", nc);
}
</code>
thanks
Dave