The following code works fine.
Code:
FILE *result;
result = fopen ("results.txt", "r");
fprintf(result, "raw array is as follows\n");//line 1
for (k=0; k<100; k++)
{
temp[k] = raw[k];
fprintf(result, "%lf\n", raw[k]);
}
fclose(result);
[\code]
k, raw and temp are initialized and everything. Works fine.
But the following code
[code]
FILE *result;
result = fopen ("results.txt", "r");
fprintf(result, "raw array is as follows\n");//line 1
for (k=0; k<100; k++)
{
temp[k] = raw[k];
if(raw[k] !=0)
{
fprintf(result, "%lf\n", raw[k]);
}
}
fclose(result);
[\code]
This does not even print line 1. I get an empty file. Any clues? Im tearing my hair over this.