John Matthews wrote:
> --- In [email protected], "David Hamill" <[EMAIL PROTECTED]> wrote:
>> Vic wrote:
>> Therefore you can compute str at runtime, e.g.:
>>
>> char *str[100]; /* <-- typo */
>> /* compute str here */
>> printf(str, i);
>
> Corrected, and using the example in the question:
>
> int i = 123;
> char str[100]; /* corrected */
> sprintf(str, "%%%di", 5); /* use %% to get % */
> printf(str, i);
> printf("\nformat used: \"%s\"\n", str);
What's wrong with:
printf("%*i", 5, i);
? A lot easier and less bug-prone. Dynamically building a string for
the first argument seems fairly dangerous to me.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/