#include #include #include int main(int argc, char *argv[]){ //int fd1 = open(argv[1],O_RDONLY); //int fd2 = open(argv[2],O_WRONLY|O_CREAT|O_TRUNC, 0666); //just one byte //int byte; //while((read(fd1, &byte, 1))>0){ // write(fd2, &byte, 1); //} // chunks //int bytes; //char buffer[1000]; //while(1){ // bytes = read(fd1, buffer, 1000); // if (bytes<=0){ // break; // } // write(fd2, buffer, bytes); //} //close(fd1); //close(fd2); FILE *f1 = fopen(argv[1],"r"); FILE *f2 = fopen(argv[2], "w"); //one byte stdio //int byte; //while((byte = fgetc(f1))!=EOF){ // fputc(byte, f2); //} char buffer[1000]; while(fgets(buffer, 1000, f1)!=NULL){ fputs(buffer, f2); } fclose(f1); fclose(f2); return 0; }