Write a ‘C’ program to do following a) Create the text file ‘input. text’ b) Print the content of file in reverse order

#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char ch;
int i,pos;
clrscr();
fp=fopen("input.txt","r+");
fseek(fp,1,SEEK_END);
pos=ftell(fp);
i=0;
while(i<=pos)
{
ch=fgetc(fp);
printf("%c",ch);
fseek(fp,-i,SEEK_END);
i++;
}
getch();
}

Comments

  1. This program does not run.what will be output above the program.

    ReplyDelete

Post a Comment