hello my dear friends;
I was reading part of a C code that i confronted with a question that i have copied and pasted for you.
my problem is in line 10 & 13 below. that I have mentioned them below.
what does a * do in this program? it has just one specifier like %d or %f but in front of it has two value. what has happened to the next one?
thanks if you answer me.
Code:
/* varwid.c -- uses variable-width output field */
#include <stdio.h>
int main(void)
{
unsigned width, precision;
int number = 256;
double weight = 242.5;
printf("What field width?\n");
scanf("%d", &width);
10 printf("The number is:%*d:\n", width, number);
printf("Now enter a width and a precision:\n");
scanf("%d %d", &width, &precision);
13 printf("Weight = %*.*f\n", width, precision, weight);
printf("Done!\n");
return 0;
}
this is it's output
What field width?
6
The number is : 256:
Now enter a width and a precision:
8 3
Weight = 242.500
Done!