#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#define N 1000000//一百万个随机数组
int main()
{
srand(time(NULL));//随机数
FILE *src = fopen("numbers.txt","w+");
setvbuf(src, NULL, _IONBF, 0);//设置缓冲模式为无缓冲
for(int i = 0; i < N; i++)
{
fprintf(src ,"%d\n", rand());//写入随机数
}
fclose(src);
return 0;
}
转载地址: