Write a program includes ALL the features:
1.Read the specify file sample.txt and then print the contents of the file on screen.
2.Print each lines of the file in reversed order on screen.
3.Print a table indicating the number of occurrences of each letter of the 4.alphabet in the sample file.
5.Print a table indicating the number of one-letter words, two-letter words, three- letter words, etc., appearing in the sample file.
sample.txt is :
all he want is like this:
screenshot
my code is :
but my code only print "I".
whats wrong with my code.. please help me..
1.Read the specify file sample.txt and then print the contents of the file on screen.
2.Print each lines of the file in reversed order on screen.
3.Print a table indicating the number of occurrences of each letter of the 4.alphabet in the sample file.
5.Print a table indicating the number of one-letter words, two-letter words, three- letter words, etc., appearing in the sample file.
sample.txt is :
Code:
I believe that children are our future Teach them well and let them lead the way Show them all the beauty they posesess inside Give them a sense of pride to make it easier Let the children's laughter remind us now we used to be
screenshot
my code is :
Code:
#include<stdio.h> #include<stdlib.h> int main() { char text[200]; FILE *cfPtr; if(( cfPtr=fopen("sample.txt","r"))==NULL) {printf("file could not be opened\n"); } else { fscanf(cfPtr,"%s",text); printf("%s\n",text); fclose(cfPtr); } return 0; }
whats wrong with my code.. please help me..
Comment