I'm writing this mex file:
for (k=0; k<MaxIter; k++){
f=fopen("results.txt", "w");
val=getValue();
fprintf(f, "%d ", val);
fclose(f);
/* do something with file information */
}
Now for (MaxIter/2)
iterations the file is created and written correctly but at (MaxIter/2)+1
iteration fopen()
return NULL
, why? maybe the file remains open?