Is a += b more efficient than a = a + b in C?
问题 I know in some languages the following: a += b is more efficient than: a = a + b because it removes the need for creating a temporary variable. Is this the case in C? Is it more efficient to use += (and, therefore also -= *= etc) 回答1: So here's a definitive answer... $ cat junk1.c #include <stdio.h> int main() { long a, s = 0; for (a = 0; a < 1000000000; a++) { s = s + a * a; } printf("Final sum: %ld\n", s); } michael@isolde:~/junk$ cat junk2.c #include <stdio.h> int main() { long a, s = 0;