43 lines
697 B
C
43 lines
697 B
C
#include <stdio.h>
|
|
#include <sys/stat.h>
|
|
#include <stdlib.h>
|
|
int main (int argc, char *argv[])
|
|
{
|
|
FILE * pq;
|
|
FILE * pz;
|
|
int ch;
|
|
unsigned long i;
|
|
struct stat statbuf;
|
|
unsigned long abzug;
|
|
|
|
|
|
if (argc != 4)
|
|
{
|
|
fprintf(stderr,"Aufruf:\n\n filecut <quelldatei> <zieldatei> <kürzungsfaktor(bytes)\n");
|
|
exit(2);
|
|
}
|
|
abzug = atoi(argv[3]);
|
|
|
|
pq = fopen (argv[1],"rb");
|
|
pz = fopen (argv[2],"wb");
|
|
if ((pq == NULL)||(pz == NULL))
|
|
{
|
|
fprintf (stderr,"\nKein Öffnen\n");
|
|
exit (4);
|
|
}
|
|
if (lstat(argv[1], &statbuf))
|
|
{
|
|
fprintf(stderr,"\nkann lstat nicht ausführen\n");
|
|
exit(3);
|
|
}
|
|
|
|
for (i=0;i<(statbuf.st_size - abzug);i++)
|
|
{
|
|
ch = fgetc(pq);
|
|
fputc(ch,pz);
|
|
}
|
|
fclose(pq);
|
|
fclose(pz);
|
|
return 0;
|
|
}
|