Hi,
I solved question but somehow it gives Segmentation fault...
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
	char ch, *string[10];
	int i = 0,j, words = 0, one = 0, two = 0,three = 0, four = 0, five = 0,\
six = 0,seven = 0, eight = 0;
	FILE *inp;
	inp = fopen("text.dat", "r");
	if(inp == NULL)
		printf("text.dat cannot be opened");
	while(fscanf(inp,"%c",&ch) == 1){
		//fscanf(inp,"%c",&ch);
		if(isspace(ch) == 0){
			fscanf(inp, "%s", string[i]);
			i++;
			words++;
		}
	}
	for(j = 0;j <= words;++j){
		if( strlen(string[j]) == 1)
			one++;
		else if( strlen(string[j]) == 2)
			two++;
		else if( strlen(string[j]) == 3)
			three++;
		else if( strlen(string[j]) == 4)
			four++;
		else if ( strlen(string[j]) == 5)
			five++;
		else if ( strlen(string[j]) == 6)
			six++;
		else if ( strlen(string[j]) == 7)
			seven++;
		else if ( strlen(string[j]) == 8)
			eight++;
	}
	printf("%d words, one letter = %d, two letter = %d, three letter = %d,\
four letter = %d, five letter = %d, six letter = %d, seven letter = %d,\
eight letter = %d", words, one, two, three, four, five, six, seven, eight);
	fclose(inp);
	return(0);
	}
text.dat
Even though she stands only 3 feet 9 inches tall, Judy Lohden has a big voice. And we're not just talking about her singing, which fills the school auditorium and wows audiences. What we love is her wry, funny narrative voice, which grabs readers and guides them through the intricate social hierarchies of cafeteria and classroom as only an outcast truly can. From the author of the hilarious memoir, Foreign Babes in Beijing, this is a novel that's filled with wit, yearning, and unforgettable character.
and gdb says(I don't know how to use gdb)
(gdb) run
Starting program: /home/mustafa/Documents/My_C_Programs/Programming_Projects/CHAPTER9/3

Program received signal SIGSEGV, Segmentation fault.
__isoc99_fscanf (stream=0x0, format=0x80488b8 "%c") at isoc99_fscanf.c:31
31 isoc99_fscanf.c: No such file or directory.
in isoc99_fscanf.c