看下面的一个例子:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d",&n);
printf("%08d",n);//中间的8代表输出的整数的指定长度,0代表不够的位数有0填充,一般都为向左填充。
return 0;
}
由上述的例子可知:
"%0ad"中的a是几就代表输出固定长度为几的整数,0代表的就是不够的位数用0填充,一般为向左填充不够的位数。
看下面的一个例子:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d",&n);
printf("%08d",n);//中间的8代表输出的整数的指定长度,0代表不够的位数有0填充,一般都为向左填充。
return 0;
}
由上述的例子可知:
"%0ad"中的a是几就代表输出固定长度为几的整数,0代表的就是不够的位数用0填充,一般为向左填充不够的位数。