Files
clearn/filecut.c

43 lines
697 B
C
Raw Normal View History

2017-02-07 20:03:49 +00:00
#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 <20>ffnen\n");
exit (4);
}
if (lstat(argv[1], &statbuf))
{
fprintf(stderr,"\nkann lstat nicht ausf<73>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;
}