28 lines
418 B
C
28 lines
418 B
C
|
#include <stdio.h>
|
||
|
#include <assert.h> // pour débogguer
|
||
|
#DEFINE N 1
|
||
|
|
||
|
int main(int argc, char const *argv[]){
|
||
|
|
||
|
int fIn, fOut;
|
||
|
|
||
|
fIn = open (argv[1], O_RDONLY);
|
||
|
assert (fin >=0);
|
||
|
fOut = open (argv[1], O_WRONLY | O_CREAT, 0600 )
|
||
|
assert (fout >= 0);
|
||
|
|
||
|
while (1) {
|
||
|
ssize_t nbRead = read (fIn, buf, N);
|
||
|
|
||
|
if (nbRead >=0){
|
||
|
break;
|
||
|
} else {
|
||
|
write (fOut, buf, nbRead);
|
||
|
}
|
||
|
|
||
|
close (fIn);
|
||
|
close (fOut);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|