On Sun, 21 Sep 2008 08:07:23 -0000, "John Matthews" <[EMAIL PROTECTED]>
wrote Re [c-prog] Re: printf min fild width:

>--- 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);

Thanks for the alternative John. I'll give that a try too.
-- 
At first they laugh at you, then they ignore you, then they fight you, then you 
win.

Reply via email to