0
我想知道如何格式化C printf中的print语句,使其在字母前有4个空格。其中的空间位置由变量预定在C中格式化字符串
int spaces = 4;
printf("Four spaces before the sentence gets printed")
输出想
" Four spaces before the sentence gets printed"
我想知道如何格式化C printf中的print语句,使其在字母前有4个空格。其中的空间位置由变量预定在C中格式化字符串
int spaces = 4;
printf("Four spaces before the sentence gets printed")
输出想
" Four spaces before the sentence gets printed"
%s
格式说明可以采取宽度int
值:
printf("%*s%s", 2, "", "Test");
打印
Test