I'm trying to write my results to a text file so I can use MATLAB for plotting and etc. and the code has no problem (i tried with just showing the results with fprint), but now that i'm trying to save the resutls to a text file, C creates the file names amiir.txt, but it is empty. Even if I use relative directories, the text file will be empty. I tried to create a text file and then run the code again, but it is empty! whats wrong? I am using mac os and i tried both XCode and CodeLight! thanks. P.S.: Here is a piece of my code:
FILE * fp; /* open the file for writing*/
fp = fopen ("/Users/amirsmacbookpro/Documents/Heat_Transfer/Project/Debug/amiir.txt","w+");
anf after some calculations:
for(i=0;i<Total_Nodes;i++)//Error
{
if(Temps_Diff[i]>Calculated_Error) Calculated_Error=Temps_Diff[i];
}
printf(fp,"\n%.4f",Calculated_Error);
// printf(fp,"\n\nROW\tColumn\tTemp\n");
for(i=0;i<=a/l;i++)//Showing results
{
for(j=0;j<=i;j++)
{
printf(fp,"%d\t%d\t%.6f\n",i,j,Temperatures[i][j]);
}
}
}
fclose(fp);