#include #include #include #include #define SZBUF 256 int main(int argc, char const *argv[]) { char buffer[SZBUF]; int f0,f1,n,m; if (argc<3) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } fs = open(argv[1],O_RDONLY); if(fs==-1) { perror("Opening source file fails"); exit(2); } fd=open(argv[2],O_WRONLY|O_TRONC|O_CREATE,0600); if(fd==-1) { perror("Opening destination file fails"); exit(3); } while(n=read(fs,buffer,SZBUF)) { m = write(fd,buffer,n) if(n==-1) { perror("writing in file fails"); exit(4); } } close(fs); close(fd); exit(0); }