I'm new to C and I'm making a simple function that will count the number of characters the program receives from user input (newline also counts as a valid character, I want to be able to do multiple instead of ending the program once user enters \n). The problem is that the program keeps expecting more input.
void main() {
int x = 0;
while (getchar() != EOF) {
x++;
}
printf("LENGTH OF INPUT: %d", x);
return;
}
I tried hitting Control+D or Control+Z to end the loop but neither of them help... Control+D appears on the terminal as ^D but the program is still running, I can still input more characters. The rest of the function (the printing function) never happens, as if the loop never ends.
My IDE is CLion on Windows.