/* in the following program read ing file from last and output char by char to another file */
/* file name : frev.c */
# include <stdio.h>
main(int argc,char*argv[])
{
FILE*f1,*f2;
int ch;
if(argc<3)
{
perror("unable to open... \n usage : frev <src file> <dest file>");
exit(0);
}
f1=fopen(argv[1],"r");
f2=fopen(argv[2],"w");
fseek(f1,0,SEEK_END);
while(fseek(f1,-2,SEEK_CUR)==0)
{
ch=getc(f1);
putc(ch,f2);
}
fclose(f1);
fclose(f2);
}
/* file name : frev.c */
# include <stdio.h>
main(int argc,char*argv[])
{
FILE*f1,*f2;
int ch;
if(argc<3)
{
perror("unable to open... \n usage : frev <src file> <dest file>");
exit(0);
}
f1=fopen(argv[1],"r");
f2=fopen(argv[2],"w");
fseek(f1,0,SEEK_END);
while(fseek(f1,-2,SEEK_CUR)==0)
{
ch=getc(f1);
putc(ch,f2);
}
fclose(f1);
fclose(f2);
}
No comments:
Post a Comment