The code below will printf out the no. of characters as 6, even if we enter only 2...
#include<stdio.h>
#include<string.h>
int main()
{
FILE *fp;
char c;
fp=fopen("random","w");
while((c=getchar())!=EOF)
putc(c,fp);
printf("\nNo. of characters = %ld",ftell(fp));
fclose(fp);
}