I was specifically trying to print integer type using %3d
but out of curiosity I want to know if it is at all possible to print %(%d)d
, considering 3
could be an integer.
Tried searching a lot online but only could find basics of %d,
%f` etc.
Asked
Active
Viewed 78 times
-1

Dharmesh Rupani
- 1,029
- 2
- 12
- 22

user45341
- 1
- 2
-
Yes, you write %*d, see the linked answer. – zwol Dec 12 '15 at 14:52
1 Answers
0
You can print on a variable width with this syntax:
printf("%*d", width, number);

chqrlie
- 131,814
- 10
- 121
- 189