0
printf("\nn = %*d", 5, 4);

and the output is:

n =     4

(yea! there are spaces between = and 4)

if i am providing only one argument 5 instead of 5 and 4 i get an error stating too few arguments. What in the world is the "*" is doing in this program. Are there any other such char which could be used in a format specifier?

Edited by rje7: n/a

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by rje7
0

The star says that you will be providing the width as an argument. In this case, the "%*d" evaluates into 5 characters (4 spaces + 1 digit).

In case you want to know more about printf format specifier, I've found this to be very good.

Edited by GuitarComet: n/a

0

thank you for the timely reply.. the link helped me a lot..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.