This code will show file content in reverse direction :
#include<stdio.h>
#include<conio.h>void main()
{
FILE *fp;
char c;
long counter=0;
clrscr();
printf(“Content of file in reverse direction : “);
fp=fopen(“c:/myfile.txt”,”r”); // file path and name
fseek(fp, -1L, 2);counter = ftell(fp);
counter++;
while (counter)
{
c = fgetc(fp);putchar(c);
fseek(fp, -2L, 1);
counter–;
}
fclose(fp);
getch();
}
Output of the code (if myfile content : Hello World):
Content of file in reverse direction : dlroW olleH