for the unknown you can read ahead to get bytes of data, figure out how to find the spaces using fgets output to 'c' then do the math to figure out what amount of data is minus spaces.
you can use 'c' to get words, spaces, lines count then work with which ever to get what you want done done.
Code:
int size = 0, count = 1;
char c = '\0';
// seek to eof
while ( (c = fgetc(in)) != EOF) {
size = ftell(in);
if ( c == ' ' )
count++;
printf("count = %d : size = %d = %c\n",count, size, c);
}
printf("words read = %d\n", count);
file contains
Code:
$ ./mallocing
count = 1 : size = 1 = 2
count = 1 : size = 2 = 3
count = 1 : size = 3 = 4
count = 2 : size = 4 =
count = 2 : size = 5 = 2
count = 2 : size = 6 = 3
count = 2 : size = 7 =
words read = 2
str = 234 23