M
Mo Geffer
Greetings:
I have a question about the output of the sample program in section
1.5.3 Line Counting of K&R, Second Edition.
Here's the program:
/****************************************/
#include <stdio.h>
/* count lines in input */
main()
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d\n", nl);
}
/****************************************/
Here's my session running the program:
/****************************************/
G4:~/c jeff$ ./linecnt
jeff
tom
2D
G4:~/c jeff$
/****************************************/
After typing 'tom' I hit <return> then type CTRL-D. The '2' is correct
but what's with the 'D'??
I ran the same program on both an OS X machine (gcc v. 3.3) and an
OpenBSD 3.3 (gcc 2.95) machine and got the same results.
So, again, what's the 'D' all about?
BTW, when I changed 'int' to 'float' and changed '%d' to '%f' the D
stopped showing up.
Thanks!
I have a question about the output of the sample program in section
1.5.3 Line Counting of K&R, Second Edition.
Here's the program:
/****************************************/
#include <stdio.h>
/* count lines in input */
main()
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d\n", nl);
}
/****************************************/
Here's my session running the program:
/****************************************/
G4:~/c jeff$ ./linecnt
jeff
tom
2D
G4:~/c jeff$
/****************************************/
After typing 'tom' I hit <return> then type CTRL-D. The '2' is correct
but what's with the 'D'??
I ran the same program on both an OS X machine (gcc v. 3.3) and an
OpenBSD 3.3 (gcc 2.95) machine and got the same results.
So, again, what's the 'D' all about?
BTW, when I changed 'int' to 'float' and changed '%d' to '%f' the D
stopped showing up.
Thanks!