c语言数据存储
我是c初学者,遇到一个问题,请教高手:同一个数据用printf输出到屏幕和用fprintf存储到文件为何数据不同?
如:
int MM;
FILE *target1,*target2;
target1 = fopen("C:\\pianzhendu_R.dat","w");
MM=10;
for(i=1;i<=MM;i++)
{
printf("%3d%%\n", (int )(100L * i / MM));
radius[i]=r_min+(r_max-r_min)*i/MM;
montecarlo( Nphotons, radius[i], rho , n_mus, lambda_media, m,S0, ST, SR);
RP= Dop_P(SR[0],SR[1],SR[2],SR[3]);
RP_L= Dop_L(SR[0],SR[1],SR[2],SR[3]);
RP_C = Dop_C(SR[0],SR[1],SR[2],SR[3]);
printf("RP= %5.5f\t RP_L= %5.5f\t RP_C=%5.5f\n ",RP, RP_L, RP_C);
fprintf(target1," %2.1f\t %5.5f\t %5.5f\t %5.5f\n ",i,RP, RP_L, RP_C);
}
fclose(target1);
[ 本帖最后由 xuanyz 于 2011-12-12 10:08 编辑 ]