.* The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.
#define SUFF ".txt"
#define MAX_STR 50
fileName[MAX_STR];
name ="myFile"
sprintf( fileName, "%s%s", name, SUFF ); //fileName = "myFile.txt"
Now I want to bound the strings with precision.
The basic thing I am trying to do (but with more dynamic calculations, which is why I am using the '*') is:
sprintf( fileName, "%.*s%.*s", 46, 4, name, SUFF );
However, even this create a run time exception.
More specifically:
sprintf( fileName, "%.*s%.*s",
MAX_STR - (int) sizeof(SUFF), (int) sizeof(SUFF),
name, SUFF );