Commit bcfcceee authored by ram's avatar ram
Browse files

Initial revision

parent 5520bc89
#include <stdio.h>
#define BUFFERSIZE (1<<21)
char buffer[BUFFERSIZE];
void chop(infile)
char *infile;
{
FILE *in, *out;
char outfile[1024];
int count, bytes;
count = 0;
in = fopen(infile, "r");
if (in == NULL) {
perror(infile);
return;
}
while ((bytes = fread(buffer, 1, BUFFERSIZE, in)) != 0) {
sprintf(outfile, "%s.%d", infile, count++);
out = fopen(outfile, "w+");
if (out == NULL) {
perror(outfile);
fclose(in);
return;
}
fwrite(buffer, 1, bytes, out);
fclose(out);
}
fclose(in);
}
main(argc, argv)
int argc;
char *argv[];
{
if (argc < 2) {
fprintf(stderr, "usage: chop file...\n");
exit(1);
}
while (*++argv != NULL)
chop(*argv);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment