#include #include #include #include #define BUFFER_SIZE 4096 char buffer[BUFFER_SIZE]; int main (int argc,char** argv) { int len = 0; if (argc < 3) { printf("Must specify two files!\n"); exit(0); } int file1 = open(argv[1],O_RDONLY,0); if (file1 < 0) { printf("Error opening file: %s\n",argv[1]); exit(0); } int file2 = open(argv[2],O_WRONLY | O_CREAT | O_TRUNC,0600); if (file2 < 0) { printf("Error opening file: %s\n",argv[2]); exit(0); } do { // TODO: check for errors! len = read (file1,buffer,BUFFER_SIZE); write(file2,buffer,len); } while (len > 0); // Intentionally ignoring errors... close(file1); close(file2); }