You're asking it to count characters until EOF, which is not end-of-line.
So you need to signal the "end-of-file" from the keyboard, which is ctrl-d on *nix, ctrl-z on Windows. It may need to be entered at the beginning of a line (or perhaps entered twice).
To count to the end of a line, compare to '\n' instead.
In the following, signal eof to quit.
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int i = 0, c = 0;
while (c != EOF) {
i = 0;
while ((c = getchar()) != EOF && c != '\n')
++i;
if (c != EOF)
printf("%d\n", i);
}
return 0;
}