#include<stdio.h>
#include<fcntl.h>
int openf(char *);
int main(int argc, char * argv[])
{
int fd,fd1, pos,i=3;
char ch;
fd = openf(argv[1]);
fd1 = openf(argv[2]);
pos = lseek(fd, 0, SEEK_END);
printf(“\n%d\n”,pos);
for(i=2; i < pos+1;i++)
{
lseek(fd, pos-i, SEEK_SET);
read(fd, &ch, 1);
write(fd1, &ch, 1);
printf(“ch = %c\n”,ch);
}
close(fd);
close(fd1);
}
int openf(char * s)
{
int fd;
fd = open(s,O_RDWR|O_CREAT,0666);
if(fd < 1)
perror(“open error”);
else
printf(“input file open succesfull fd = %d\n”,fd);
return fd;
}