\* C file handling program to print contents of file in reverse order *\
# include < stdio.h >
# include < string.h >
# include < stdlib.h >
int main( int argc, char *argv[] )
{
FILE *fp1 ;
char filename[15] ;
int cnt = 0 ;
int i = 0 ;
printf("\n Enter the filename to be opened : ") ;
scanf("%s", filename ) ;
fp1 = fopen(filename, "r") ;
if (fp1 == NULL)
{
printf("\n %s File can not be opened : \n", filename) ;
exit(0) ;
}
fseek( fp1, 0, SEEK_END ) ;
cnt = ftell(fp1) ;
while( i < cnt )
{
i++ ;
fseek( fp1, -i, SEEK_END ) ;
printf("%c", fgetc(fp1)) ;
}
printf("\n") ;
fclose(fp1) ;
return 0 ;
}