Si,infatti avevo considerato che non ci fossero spazi.

Questo considera anche gli spazi :

codice:
#include <stdio.h>
#include <string.h>
main() 
{
	FILE *file = fopen ("text.txt","r");
	FILE *fileOut = fopen ("result.txt","w");		
	
	char buffer[100];
	int i=0;
	char *string;
	int spaces = 0;

	while (fgets(buffer,100,file) != NULL)
	{
		string = strtok(buffer,"\n\t\r");
		
		while (string[i] == (i-spaces+48) || string[i] == ' ')	
		{	
			if (string[i] == ' ')
				spaces++;
			i++;
		}
		
		fprintf(fileOut,"%d\n",i-spaces);

		i = 0;
		spaces=0;
	}	
	

}