c++ - Align text and change amount of spaces -
i'm trying format string, becouse have 2 strings 1 contain: "1" ,
second contain: "test" , want output whole string space as:
1 test
i did saying:
printf("%-10s %s", "1", "test");
but how change space " %-10s " without changing format?
int amount_of_space = 10; like: printf("%-*s %s", "1", "test", amount_of_space)
how do that??? in c or c++, please me out
printf("%-*s %s", amount_of_space, "1", "test" ) ;
the * comes first in format string - hence parameter amount_of_space
has come first after comma.
i.e in format string order *, s & s - after comma, need whatever fills in *, first string , 2nd string.
Comments
Post a Comment