G
guidosh
Hello,
I'm trying to write a printf statement that sets the field width when
printing a number. I'm using this:
printf("%*", fieldwidth, num_to_print);
However, I can't figure out how to get the number of digits in the
number (which I would then assign to the 'fieldwidth' variable above).
I know I don't have to explicitly set the field width with printf, but
I would like very much to know how to discover it.
Can anyone suggest how I might get the number of digits for a numeric
variable?
Thanks...
I'm trying to write a printf statement that sets the field width when
printing a number. I'm using this:
printf("%*", fieldwidth, num_to_print);
However, I can't figure out how to get the number of digits in the
number (which I would then assign to the 'fieldwidth' variable above).
I know I don't have to explicitly set the field width with printf, but
I would like very much to know how to discover it.
Can anyone suggest how I might get the number of digits for a numeric
variable?
Thanks...