2021-10-02 11:22:47 +02:00
|
|
|
#include <stdlib.h>
|
2021-10-04 13:36:54 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2021-10-02 11:22:47 +02:00
|
|
|
|
2021-10-04 13:36:54 +02:00
|
|
|
#define N 1
|
2021-10-02 11:22:47 +02:00
|
|
|
|
|
|
|
|
2021-10-04 13:36:54 +02:00
|
|
|
int main(int argc, char const *argv[]) {
|
|
|
|
|
|
|
|
int fIn, fOut;
|
|
|
|
char buff [N];
|
|
|
|
|
|
|
|
fIn = open (argv[1], O_RDONLY);
|
|
|
|
assert (fIn >= 0);
|
|
|
|
|
|
|
|
fOut = open (argv[2 ], O_WRONLY | O_CREAT, 0600);
|
|
|
|
assert (fOut >=0);
|
|
|
|
|
|
|
|
while (1){
|
|
|
|
ssize_t nbRead = read (fIn, buff, N);
|
|
|
|
|
|
|
|
if (nbRead <=0) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
write (fOut, buff, N);
|
|
|
|
}
|
2021-10-02 11:22:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-04 13:36:54 +02:00
|
|
|
close (fIn);
|
|
|
|
close (fOut);
|
|
|
|
|
|
|
|
|
2021-10-02 11:22:47 +02:00
|
|
|
}
|