I don't figure out how to tell printf to print a double with a variable precision.
Where is what I actually do :
int main(void)
{
int digits = 4;
printf("%0.*f\n", digits, 0.123456789);
printf("%0.*f\n", digits, 5.9);
return (0);
}
I actually have the variable precision with the * and the digits variable, but it still prints remaining 0 after the last number.
In order to illustrate my problem, here is what i get :
0.1234
5.9000
And here is what i want :
0.1234
5.9
Could you help me please?