What is the difference between %d and %*d in c language?
问题 What is %*d ? I know that %d is used for integers , so I think %*d also must related to integer only? What is the purpose of it? What does it do? int a=10,b=20; printf("\n%d%d",a,b); printf("\n%*d%*d",a,b); Result is 10 20 1775 1775 回答1: The %*d in a printf allows you to use a variable to control the field width, along the lines of: int wid = 4; printf ("%*d\n", wid, 42); which will give you: ..42 (with each of those . characters being a space). The * consumes one argument wid and the d