I was reading Kernighan Ritchie and there's this Character counting program, so I tried implementing
#include <stdio.h>
#include <stdlib.h>
int main()
{
char c;
int i;
c = getchar();
while (c != EOF)
i= i + 1;
printf("%d",i);
}`
When I compile and run this code, after I enter some characters there's no output after that. No number is printed and I can't figure out why. The code looks fine. I also tried using scanf() but the same thing happened.
The next example was for counting lines in input and the same problem was there too.