1. 只有加上%10d的时候(10只是举的例子),这时候限定了int值输出长度为10,而12345这个int值的长度为5,这时候就有左对齐还是右对齐的分别了。
#include <stdio.h>
void main()
{
https://img-blog.csdn.net/20140312113607984?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenk4MjM4ODgwOTg=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
printf("%10d\n%10d\n%10d\n",12345,1234,123);
}
2. 如果使用%-10d这时候就是:
https://img-blog.csdn.net/20140312113706203?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenk4MjM4ODgwOTg=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
#include <stdio.h>
void main()
{
https://img-blog.csdn.net/20140312113607984?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenk4MjM4ODgwOTg=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
printf("%10d\n%10d\n%10d\n",12345,1234,123);
}
2. 如果使用%-10d这时候就是:
https://img-blog.csdn.net/20140312113706203?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenk4MjM4ODgwOTg=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast