gpt4 book ai didi

c -++nc 与 nc = nc + 1

转载 作者:太空狗 更新时间:2023-10-29 15:11:36 26 4
gpt4 key购买 nike

在 K&R 第 1 章中:

The statement ++nc presents a new operator, ++, which means increment by one. You could instead write nc = nc + 1, but ++nc is more concise and often more efficient.

预增量什么时候比替代方案更有效?对于大多数事情,至少,两者的汇编是add(编辑:或inc)指令。它们什么时候不同?

最佳答案

该文本早已过时。在 70 年代,编译器可能会为++n 产生更高效的输出,这可能是真的,但现在不会了。所有现代编译器都会生成相同的代码。

关于c -++nc 与 nc = nc + 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8614001/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com