the above mentioned displays the contents of the files one by one (ie) each WORD in reverse order followed by a new line character.....
SAMPLE i/p :
ur file contains
: I LOVE MY MOTHER INDIA
ANALYSIS OF THE PROGRAM
since in this program , a FILE contents is gonna be made use of , a file pointer is been declared. (line 5)
since you are going to store the file contents by taking it as WORD by WORD , that word is goin to be stored in a temperory Buffer array. (line 6)
but in file u can read only by character by character , to first read it from the file we have a character variable read1. (line 7)
for indexing that buffer array we have a index as a variable .(line 8)
for opening a file . we must use the function fopen() function..... inside that function the first argument is the file name , second is the opening mode of that file.. here opening mode is "r+" , where we can both read as well as write (used for updation)..
now comes a very important string function , memset(); ,
THE SYNTAX OF THIS IS
: void memset (char *s , unsigned char ch , int bytes)
a) where 's' denotes the starting address of the array , 'ch' refers to a particular character , 'bytes' refers , Till how many bytes i have to replace the character specified by 'ch' .....
b) then after using the function , upto the specified bytes it will be replaced by that character u have mentioned by 'ch'......
now he has used , this function ..... so it fills the character '\0' upto 100 bytes of memory in the buffer array......
now the program starts reading from the file , read1 gets character by character from the file pointer 'file_pointer'... and simultenously checks for END OF FILE (EOF)....
so next statement is , it is checking for spaces or Newline character.... since one of the termination condition for a word in english is SPACE or A NEW LINE... so the program checks for it........
A) if the above if condition becomes TRUE
(ie) if the file encounters SPACE or A NEW LINE , the present buffer index is made '\0' and sent to a function called string_reverse_function()
, This function will thus reverse the string which is passed as an argument.......... LIKE THIS IT MOVES............... ........... ...... ...
B) if the Above if statement is a FALSE
(ie) the file is not encountering any SPACES or A NEW LINE , character by character is copied to the buffer array
11) Thus the program runs , and when the file encounters the EOF the while loop will terminate ................
hope this helps u .....