While reading input character by character, CTRL-D should activate the EOF symbol and exit the loop and execute the printf statement after the loop. However, CTRL-D exits the program entirely.
#include <stdio.h>
#include <ctype.h>
int main() {
int current_character, next_character;
int amount_of_characters = 0, amount_of_words = 0, amount_of_newlines = 0;
while( (current_character = getchar()) != EOF) {
amount_of_characters++;
}
printf("%d", amount_of_characters);
return 0;
}