#include // open, close, O_RDONLY, ... #include // perror #include // read, write int main(int argc, char* argv[]) { int f1 = open(argv[1], O_RDONLY); if (f1 < 0) { perror("open"); return 1; } int f2 = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0755); if (f2 < 0) { perror("open"); return 2; } char buf; while(read(f1, &buf, 1)) { write(f2, &buf, 1); } close(f1); close(f2); }