I have searched the site and I haven’t found an answer to my problem.
My program outputs an image, and I want to save to a different file, each image produced after an cycle iteration.
My code to save files is this
FILE *fobjecto;
if ((fobjecto = fopen ("OSEM.ima", "wb")) != NULL)
{
printf("Writing reconstructed image file");
fwrite (objecto, sizeof(float), (detectorXDim)*detectorYDim*(NSlices-1), fobjecto);
fclose (fobjecto);
}
else
printf("Reconstructed image file could not be saved");
I want to add one integer variable to the output file’s name, I have tried playing with “+” and “,” but I could not solve it.
Thanks in advance
You will need some formatted output operation like
sprintf(or even better its safe twinsnprintf):