22 lines
606 B
C
22 lines
606 B
C
#include <stdio.h>
|
|
|
|
int copy_file(const char *a, const char *b)
|
|
{
|
|
FILE *x = fopen(a, "rb"); if (!x) return -1;
|
|
FILE *y = fopen(b, "wb"); if (!y) { fclose(x); return -1; }
|
|
int c, n = 0;
|
|
while ((c = fgetc(x)) != EOF)
|
|
{
|
|
fputc(c, y);
|
|
n++;
|
|
}
|
|
fclose(x);
|
|
fclose(y);
|
|
return n;
|
|
}
|
|
|
|
int compress_1(const char *a, const char *b){return copy_file(a,b);}
|
|
int compress_2(const char *a, const char *b){return copy_file(a,b);}
|
|
int decompress_1(const char *a, const char *b){return copy_file(a,b);}
|
|
int decompress_2(const char *a, const char *b){return copy_file(a,b);}
|