Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试过
printf("%s %15s", string1, string2);
我发现这种左填充取决于与第一个字符串的距离,如果我想要一个从最左边开始计数的绝对左填充怎么办?
您想在右侧填充第一个字符串,而不是在左侧填充第二个字符串:
printf("%-15s %s",string1,string2);