为什么printf(“**% d**",-31);
结果是**-31**
而不是** -31**
而printf(“**% d**",31);
结果就是** 31**
(为什么上面打印出来没有空格,而下面的打印出来就有空格)
c语言学习(printf的使用)
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
5条回答 默认 最新
_GX_ 2022-09-09 13:46关注% d中的空格表示,如果输出结果没有符号,则在前面加一个空格
https://en.cppreference.com/w/c/io/fprintfspace: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present.
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用