As already said use <Ctrl>+'Z' to generate EOF in windows, but to get accurate count of characters before ^Z unbuffer the standard input:
#include <stdio.h>
int main(void)
{
long nc;
nc = 0;
setvbuf(stdin, NULL, _IONBF, 0);
while (getchar() != EOF)
++nc;
printf("%d\n", nc);
return 0;
}
The long holds the count not the input.