37 lines
528 B
C
37 lines
528 B
C
|
#include <fcntl.h>
|
||
|
#include <unistd.h>
|
||
|
#include <assert.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.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 >= 0 );
|
||
|
|
||
|
fout = fopen(argv[2],"w");
|
||
|
assert( fout >= 0 );
|
||
|
|
||
|
while(1){
|
||
|
ssize_t nb_read;
|
||
|
nb_read = fread(buf,sizeof(char),BLOCK_SIZE,fin);
|
||
|
if (nb_read <= 0)
|
||
|
break;
|
||
|
fwrite(buf,sizeof(char),BLOCK_SIZE,fout);
|
||
|
}
|
||
|
|
||
|
fclose(fin);
|
||
|
fclose(fout);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|