33,311
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
const int KSize = 1024 * 1024;
int main(int argc, char* argv[])
{
int ch = 0;
if (argc > 1)
ch = *argv[1];
char filebuf[KSize];
memset(filebuf, ch, KSize);
FILE* pFile;
char filename[256] = {0};
filename[0] = ch;
if (argc == 1)
filename[0] = '0';
for (int f = 0 ; f != 1024 ; ++f) { // 测试文件可以只写5 测试 5个 512M的文件
sprintf(filename + 1, "%04d" , f);
pFile = fopen(filename , "wb");
for (int i = 0 ; i != 512; ++i) {
ch = fwrite(filebuf , 1 , sizeof(filebuf) , pFile);
if (ch == 0) {
while (ch = fwrite(filebuf , 1 , 1024 , pFile))
;
printf("不能再写了\n最后一个文件名%s\n", filename);
return 88;
}
}
printf("输出文件名: %s\n", filename);
fclose(pFile);
}
return 0;
}
D:\XP_C>tt r:\atl\Zero\Zero.exe A
输出文件名: A0000
输出文件名: A0001
输出文件名: A0002
输出文件名: A0003
输出文件名: A0004
输出文件名: A0005
输出文件名: A0006
输出文件名: A0007
输出文件名: A0008
输出文件名: A0009
输出文件名: A0010
输出文件名: A0011
不能再写了
最后一个文件名A0012
Process returned 88 (0x58) execution time : 127.563 s
进程返回 88 (0x58) 执行时间 : 127.563 秒
请按任意键继续...