#ccccciii 2022-09-09 12:47 采纳率: 80%
浏览 130
已结题

c语言学习(printf的使用)

为什么printf(“**% d**",-31);
结果是**-31**
而不是** -31**
而printf(“**% d**",31);
结果就是** 31**
(为什么上面打印出来没有空格,而下面的打印出来就有空格)

  • 写回答

5条回答 默认 最新

  • _GX_ 2022-09-09 13:46
    关注

    % d中的空格表示,如果输出结果没有符号,则在前面加一个空格
    https://en.cppreference.com/w/c/io/fprintf

    space: 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 9月9日
  • 已采纳回答 9月9日
  • 创建了问题 9月9日