//写入文件
<span style="font-size:14px;">FILE *ff;
ff=fopen("f:\\yu.txt","w"); //记录每次搜索移动次数
for(int i=0;i<MAX;i++)
{
fprintf(ff,"%d \n",num[i]);
}
fclose(ff);
printf("\n记录次数完成\n"); </span>
<span style="font-size:14px;">const char file_name[50] = "f:\\22.txt";//文件路径
FILE *fp;
int index[N] = {0}; //二维数组列下标
double temp;
int i, j;
int count = 0; //计数器,记录已读出的浮点数
if((fp=fopen(file_name, "rb")) == NULL) {
printf("请确认文件(%s)是否存在!\n", file_name);
exit(0);
}
while(1==fscanf(fp, "%lf", &temp)) {
data[count%N][(index[count%N])++] = temp;
count++;
}</span>