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?

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.