Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个关于C语言putchar函数的问题。在学习的时候,我偶然发现了以下语句: printf("%c\n",putchar('A'+1)+2); 当我编译并执行程序时,结果是BD。我不明白当我们键入putchar('A' + 1)结果时会是 B,但是我们是如何得到 D 的?这个函数不是一次返回一个字符吗?提前致谢
printf("%c\n",putchar('A'+1)+2);
putchar('A' + 1)
putchar正在做两件事:
putchar
stdout
由于 'B' 是由 返回的putchar,所以它添加了 2 使其成为 'D'。这作为参数传递printf,然后将“D\n”写入stdout.
printf