C输出的左对齐和右对齐

时间:2025-03-08 08:21:06

输出的左对齐和右对齐

默认右对齐

#include <>
int main()
{
    printf("%10d\n", 1234);    //右对齐。数字宽度为10,若不足10,在左边补足空格
    printf("%-10d\n", 1234);   //左对齐。数字宽度为10,若不足10,在右边补足空格
    return 0;
}

相关文章