新手写的一个好繁琐的程序,高手入
别笑啊看看还能在简化下吗,我怕以后要是分成128或者256个文件手会酸死
//把1个文件分解成64份,其中按一个文件512字节的顺序放入新文件
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
FILE *f0,*f1,*f2,*f3,*f4,*f5,*f6,*f7,*f8,*f9,*f10,*f11,*f12,*f13,*f14,*f15,*f16,*f17,*f18,*f19,*f20,*f21,*f22,*f23,*f24,*f25,*f26,*f27,*f28,*f29,*f30,*f31,*f32,*f33,*f34,*f35,*f36,*f37,*f38,*f39,*f40,*f41,*f42,*f43,*f44,*f45,*f46,*f47,*f48,*f49,*f50,*f51,*f52,*f53,*f54,*f55,*f56,*f57,*f58,*f59,*f60,*f61,*f62,*f63,*f64;
if((f1=fopen("01.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f2=fopen("02.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f3=fopen("03.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f4=fopen("04.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
}
if((f5=fopen("05.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f6=fopen("06.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f7=fopen("07.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f8=fopen("08.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f9=fopen("09.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f10=fopen("10.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f11=fopen("11.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f12=fopen("12.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f13=fopen("13.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f14=fopen("14.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f15=fopen("15.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f16=fopen("16.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f17=fopen("17.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f18=fopen("18.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f19=fopen("19.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f20=fopen("20.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f21=fopen("21.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f22=fopen("22.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f23=fopen("23.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f24=fopen("24.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f25=fopen("25.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f26=fopen("26.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f27=fopen("27.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f28=fopen("28.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f29=fopen("29.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f30=fopen("30.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f31=fopen("31.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f32=fopen("32.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f33=fopen("33.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f34=fopen("34.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f35=fopen("35.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f36=fopen("36.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f37=fopen("37.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f38=fopen("38.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f39=fopen("39.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f40=fopen("40.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f41=fopen("41.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f42=fopen("42.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f43=fopen("43.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f44=fopen("44.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f45=fopen("45.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f46=fopen("46.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f47=fopen("47.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f48=fopen("48.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f49=fopen("49.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f50=fopen("50.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f51=fopen("51.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f52=fopen("52.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f53=fopen("53.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f54=fopen("54.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f55=fopen("55.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f56=fopen("56.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f57=fopen("57.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f58=fopen("58.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f59=fopen("59.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f60=fopen("60.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
} if((f61=fopen("61.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
} if((f62=fopen("62.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f63=fopen("63.bin","wb"))==NULL)
{
printf("cannot open file A\n");
exit(0);
}
if((f64=fopen("64.bin","wb"))==NULL)
{
printf("cannot open file B\n");
exit(0);
}
if((f0=fopen("C.bin","rb"))==NULL)
{
printf("cannot open file C\n");
exit(0);
}
char buffer[512];
//先获取文件长度;
long len,i;
fseek(f0,0,2);
len=ftell(f0);
fseek(f0,0,0);
for(i=len;i>0;i-=32768)/*一次处理了4子节*/
{
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f1);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f2);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f3);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f4);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f5);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f6);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f7);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f8);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f9);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f10);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f11);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f12);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f13);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f14);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f15);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f16);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f17);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f18);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f19);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f20);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f21);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f22);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f23);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f24);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f25);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f26);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f27);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f28);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f29);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f30);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f31);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f32);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f33);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f34);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f35);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f36);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f37);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f38);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f39);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f40);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f41);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f42);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f43);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f44);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f45);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f46);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f47);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f48);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f49);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f50);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f51);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f52);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f53);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f54);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f55);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f56);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f57);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f58);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f59);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f60);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f61);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f62);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f63);
fread(buffer,sizeof(buffer),1,f0);
fwrite(buffer,sizeof(buffer),1,f64);
}
fclose(f0);
fclose(f1);
fclose(f2);
fclose(f3);
fclose(f4);
fclose(f5);
fclose(f6);
fclose(f7);
fclose(f8);
fclose(f9);
fclose(f10);
fclose(f11);
fclose(f12);
fclose(f13);
fclose(f14);
fclose(f15);
fclose(f16);
fclose(f17);
fclose(f18);
fclose(f19);
fclose(f20);
fclose(f21);
fclose(f22);
fclose(f23);
fclose(f24);
fclose(f25);
fclose(f26);
fclose(f27);
fclose(f28);
fclose(f29);
fclose(f30);
fclose(f31);
fclose(f32);
fclose(f33);
fclose(f34);
fclose(f35);
fclose(f36);
fclose(f37);
fclose(f38);
fclose(f39);
fclose(f40);
fclose(f41);
fclose(f42);
fclose(f43);
fclose(f44);
fclose(f45);
fclose(f46);
fclose(f47);
fclose(f48);
fclose(f49);
fclose(f50);
fclose(f51);
fclose(f52);
fclose(f53);
fclose(f54);
fclose(f55);
fclose(f56);
fclose(f57);
fclose(f58);
fclose(f59);
fclose(f60);
fclose(f61);
fclose(f62);
fclose(f63);
fclose(f64);
system("pause");
}