@frezzy
I think you were looking for this:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
double val = 12.3456789;
int places = 0;
if(argc != 2)
{
printf("USAGE: %s [decimal place int]\n", argv[0]);
printf("Example: %s 2 (For two decimal places)\n", argv[0]);
exit(EXIT_FAILURE);
}
else
{
places = atoi(argv[1]);
}
printf("%d Decimal places: %.*lf\n", places, places, val);
return 0;
}
Use the '*' char to fill in the field width of the decimal portion in the format string, input by the user.