Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // split 07/98 by bingen@lastresort.net
- // for m.siefen
- //
- #include <stdio.h>
- #include <stdlib.h>
- #include <io.h>
- #include <string.h>
- #include <dos.h>
- #include <direct.h>
- #define TRUE 1
- #define FALSE 0
- #define OUTFILE "OUT"
- void usage(void)
- {
- printf(".compiled with watcom c/c++ 11.0. edited with zeus32 2.60.\n\n");
- printf(".status: freeware. use as often as you want.\n");
- printf(".purpose: splitting large ascii-files.\n\n");
- printf(".usage: SPLIT filename [splitsize]\n");
- exit(-1);
- }
- void main(int argc, char *argv[])
- {
- FILE *stream;
- FILE *stream2;
- int i, splitsize;
- char l=0;
- char str[255];
- char out[255];
- char in[255];
- printf("SPLIT v0.1 - (c)1998 by bingen@lastresort.net\n");
- if (argc==1) usage();
- if (argc>1) strcpy(in, argv[1]);
- if (argc>2)
- splitsize=atoi(argv[2]);
- else
- splitsize=100;
- printf("..splitting %s (%d lines each)\n",in,splitsize);
- sprintf(out,"%s%d",OUTFILE,l);
- stream=fopen(in,"r");
- if(stream!=NULL)
- {
- while(!feof(stream))
- {
- stream2=fopen(out,"w");
- if(stream2!=NULL)
- {
- for (i=1;i<=splitsize;i++)
- {
- if(fgets(str,255, stream)!=NULL)
- {
- fputs(str, stream2);
- printf("%s -> %d \r", out, i);
- }
- else
- i=splitsize;
- }
- fclose(stream2);
- l++;
- }
- sprintf(out,"%s%d",OUTFILE,l);
- printf("\n");
- }
- fclose(stream);
- }
- else
- printf("..file not found!\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement