#include #include #include #include int main(void) { char c; int src, dst; int count; src = open("src", O_RDONLY); if (src < 0) { perror("src"); exit(1); } dst = open("dst", O_WRONLY | O_CREAT | O_TRUNC, 0666); if (dst < 0) { perror("dst"); close(src); exit(1); } while ((count = read(src, &c, 1)) > 0) { if (write(dst, &c, count) < 0) { perror("write"); exit(1); } } if (count < 0) { perror("read"); exit(1); } close(src); close(dst); return 0; }