How do I write an array of y[7990272] values to a text file (opened using the fopen() function) in a 2448×3264 order (so each row in the text file has 2448 values).
FILE *fp;
fp=fopen("output.txt","w");
for(int i=0;i<7990272;i++)
{
fprintf(fp,"%f\n",y[i]);
}
fclose(fp);
The residual issue is that there won’t be any spaces between the numbers as written. There are various ways to handle that; I usually use a variation on:
If you don’t like the recomputation of the array subscript, you can keep another variable that simply increments monotonically: