Originally Posted by
fclopez
What i want to do is if I call someFunction (....), I want someNumber to be free so that i can use the variables begin and end to replace it , so that
someFunction("/home/myComputer/someFolder/fileName_%d.raw", begin, end);
You have to first create the format string by concatenating all the parts (including the %d format specifier) and then later use this format string:
Code:
#include <stdio.h>
int main(void)
{
char *string0 = "/home/myComputer/someFolder/fileName_";
char ext[4] = ".raw";
char fname[256];
puts("Create format string for later processing:");
sprintf(fname, "%s%s%s", string0, "%d", ext);
puts(fname);
int begin = 0, end = 10, i;
puts("\nNow insert number into created format string:");
for (i = begin; i < end; i++)
{
printf(fname, i);
putchar('\n');
}
return 0;
}
Is that what you want?
Bye, Andreas