Is there any way to have a user inputed float format specifier? For example, if I print this.
float c = 15.0123 printf(\"%.2f\", c); // outputs: 15.01
The precision can be specified by an argument with the asterisk *. This is called an argument-supplied precision.
*
float c = 15.0123; int m = 2; printf("%.*f", m, c);
printf("%.*f", n, c); that will print out c with n places after the decimal.
printf("%.*f", n, c);