#include
main()
{
FILE *fp,*ft;
char c;
long int pos;
/*assume that a file ,conten.c and rev.c exit already*/
fp=fopen("conten.c","r");
ft=fopen("rev.c","w");
pos=ftell(fp);
/*printf("%ld",pos);*/
fseek(fp,-1,2);
while(ftell(fp)>pos)
{
c=fgetc(fp);
fseek(fp,-2,1);
fputc(c,ft);
printf("%c",c);
}
c=fgetc(fp);
printf("%c",c);
fputc(c,ft);
fclose(fp);
fclose(ft);
}
plese check it ..if u need
ReplyDelete