C
CBFalconer
Kenneth said:.... snip ...
It could be a bug in Windows and/or the C runtime.
Change the printf() line to read:
printf("aefore newline\nafter newline %ld\n",nc);
On Windows 98, with MSVC 6.0a (compiler version 12.00.8168) typing
"foobar" newline Ctrl-Z newline, I get:
foobar
after newline 7
Note that everything in the printf() prior to the newline is gone.
On Windows XP:
foobar
^Z
before newline
after newline 7
And the program has not yet exited. I need to press Enter one
more time to get the program to exit.
It's not W98 FE. Under that, and DJGPP 2.03, gcc 3.3.1:
[1] c:\c\junk>gcc junk.c
[1] c:\c\junk>a
Bloody nonsense
^Z
16
[1] c:\c\junk>type junk.c
#include <stdio.h>
int main(void)
{
long nc;
nc = 0;
while (getchar() != EOF) ++nc;
printf("%ld\n", nc);
return 0;
}