This commit is contained in:
2025-10-02 14:46:01 +02:00
parent ced39240a2
commit 24e505f788
3 changed files with 0 additions and 0 deletions

36
tp1/ex1/copy_stdio.c Normal file
View File

@@ -0,0 +1,36 @@
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#define BLOCK_SIZE 1
int main(int argc, char *argv[])
{
FILE* fin,
* fout;
char buf[BLOCK_SIZE];
assert( argc == 3 );
fin = fopen(argv[1], "r");
assert( fin != NULL );
fout = fopen(argv[2],"w");
assert( fout != NULL );
while(1){
ssize_t nb_read;
nb_read = fread(buf,BLOCK_SIZE,1,fin);
if (nb_read <= 0)
break;
fwrite(buf,BLOCK_SIZE,nb_read,fout);
}
fclose(fin);
fclose(fout);
return 0;
}