View Single Post
  #2 (permalink)  
Old 06-14-2008, 07:38 PM
James's Avatar   
James James is offline
Newbie
 
Join Date: Jun 2008
Posts: 1
Credits: 0
Rep Power: 0
James is on a distinguished road
Default Re: a problem in C pre specifire

Referencing to this site: cplusplus.com/reference/clibrary/cstdio/printf.html

Looks as if

Code:
// %[flags][width][.precision][length]specifier  
// the flag specifier isn't used in either of these
// %*d the * means to take the next argument
// in this case width to printf as size of field
10 printf("The number is:%*d:\n", width, number);

printf("Now enter a width and a precision:\n");

scanf("%d %d", &width, &precision);

// %*.*f... * means same as above take width as size of field
// .* meaning to take the following argument precision to printf 
// to set the precision of the number specified by the variable set by the user
13 printf("Weight = %*.*f\n", width, precision, weight);

Last edited by WingedPanther; 06-15-2008 at 08:23 AM. Reason: add code tags
Reply With Quote