I am currently learning the C language by coding along to 'The C Programming Language (2nd Edition). The book features this program: upon creation and compilation of this program everything seems to run smoothly:
but when i run the program, it doesn't seem to work:
why is this?
Asked
Active
Viewed 43 times
0

Michael Hanson
- 323
- 4
- 12
-
How are you sending the EOF character? – Mureinik May 11 '19 at 20:30
-
Because the program has no way of knowing that you have finished typing input unless you signal end of file. – rici May 11 '19 at 20:31
-
3To send an EOF from the keyboard: Ctrl-D on linux or mac, Ctrl-Z on windows. – user3386109 May 11 '19 at 20:32
-
You can either use `^D` to terminate terminal input, or you can redirect `stdin` from a file, e.g. `./character_counting < file.txt` – Tom Karzes May 11 '19 at 20:40
-
1It does not print the number of characters typed until the loop has ended. – Weather Vane May 11 '19 at 20:41