数组文本写入写不进去是什么问题
float s = 0;FILE *g;
g = fopen("时空图.txt", "a");
for (i = 0; i < car_num; i++)
{
temp_1 = p[i];
speed = v[i][temp_1];
gap = FindFront(i);
if (speed + 1 <= vmax)
speed++;
if (speed > gap)
speed = gap;
if (speed > 0 && rand_double() <= pi)
speed--;
temp_2 = (temp_1 + speed) % lane; //位置更新
p[i] = temp_2;
v[i][temp_2] = speed;
a[i] = speed - v[i][temp_1];
if (speed > 0)
v[i][temp_1] = -1;
if (a[i] > 0 || a[i] == 0)
{
tor[i] = (mg*(0.0076 + 0.000056*speed) + 0.5*0.3*1.2258*8.25*speed * speed + 1.1*mg / 10 * a[i])*r; //扭矩
pe[i] = tor[i] / (0.8*0.95*0.8)*(speed / r*0.8*0.95);
pm[i] = pe[i] / (367.1 * 7);
}
//fprintf(g, "第1辆车的油耗:%2f\n", pm[0]);
/*if (temp_2 == p[(i + 1) % lane])
{
printf("撞车了,位置为:%2d ,编号为;%2d", p[i], i);
}*/
s += pm[i];
}
fprintf(g, "耗油:%2f\n", s/time_count);
结果是文本文件g中什么也没有