blob: f44e44dafcf7246f19de4531d23a12cab460ff33 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int f1 = open(argv[1], O_RDONLY);
if (f1 == -1) return 1;
int f2 = open(argv[2], O_CREAT | O_WRONLY | O_TRUNC, 0755);
if (f2 == -1) return 2;
char buf;
while(read(f1, &buf, 1)) {
write(f2, &buf, 1);
}
close(f1);
close(f2);
}
|