#include<stdio.h>
#include<process.h>
void check(int);
int count(char *);
void split(char *,int,int);
int main(int argc,char *argv[])
{
int words,n;
words=count(argv[1]);
printf("Enter split number : ");
scanf("%d",&n);
printf("Summary\n");
printf("================================================\n");
printf("Source file :%10s\n",argv[1]);
printf("Output file(s) :%10s\n",argv[2]);
for (int k=3;k<n+2;k++)
{
printf(" %10s\n",argv[k]);
}
FILE *fp1;
fp1=fopen(argv[1],"rb");
int temp,i,j;
temp= (words%n == 0 ? words/n : words/n+1);
char ch;
for(j=2;j<n+2;j++)
{
FILE *fp;
fp=fopen(argv[j],"wb");
for(i=0;i<temp;i++)
{
ch=getc(fp1);
putc(ch,fp);
}
fclose(fp);
}
fclose(fp1);
return 0;
}
int count(char *pi)
{
FILE *fp;
fp=fopen(pi,"rb");
for(int i=0;getc(fp) != EOF;)
i++;
fclose(fp);
return i;
}
To be continued...
--
--
※ 發信站: 批踢踢實業坊(ptt.twbbs.org)
◆ From: tp222-41.dialup