Reputation: 5821
I was wondering how I could format the print statement in a C printf to have 4 spaces before the letter. Where the space position is predetermined by a variables
int spaces = 4;
printf("Four spaces before the sentence gets printed")
output would like
" Four spaces before the sentence gets printed"
Upvotes: 0
Views: 105
Reputation: 24439
%s
format specifier can take width as int
value:
printf("%*s%s", 2, "", "Test");
prints
Test
Upvotes: 1