新手,把100M分成100份,每份1M,错在哪?
#include<stdio.h>#include<stdlib.h>
char *date( char *str,int m);
int main(int argc,char *argv[])
{
FILE *f,*fp;
int part=104857600,i,j;
void *tmps;
if((f=fopen("test.txt","rb+"))==NULL)
{
printf("can't open this file");
exit(1);
}
tmps=(char *)malloc(part);
{
for(i=1;i<=100;i++)
{
if((fp=fopen(date(argv[1],i),"wb+"))==NULL)
{
printf("error");
exit(2);
}
for(j=0;j<1024;j++)
{
fread(tmps,sizeof(char),1024,f);
fwrite(tmps,sizeof(char),1024,fp);
}
fclose(fp);
}
}
fclose(f);
return 0;
}