Why does n++ execute faster than n=n+1?

前端 未结 10 1018
[愿得一人]
[愿得一人] 2021-01-30 22:05

In C language, Why does n++ execute faster than n=n+1?

(int n=...;  n++;)
(int n=...;  n=n+1;)

Our instructor asked

10条回答
  •  抹茶落季
    2021-01-30 22:26

    All those things depends on compiler/processor/compilation directives. So make any assumptions "what is faster in general" is not a good idea.

提交回复
热议问题