作业帮 > 综合 > 作业

int y=1234;printf(“y=%+06d\n”),结果为什么是y=+01234?

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/15 16:21:25
int y=1234;printf(“y=%+06d\n”),结果为什么是y=+01234?
+表示 右对齐;
0表示 补零;
6 表示 占6个长度;
为什么还有个+ 号 ?、
加号"+"表示强制显示正负号(+和-).默认是右对齐,想要左对齐就用减号"-".
参考:
- Left-justify within the given field width; Right justification is the default (see width sub-specifier).
+ Forces to precede the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign.