宏交换同一个数问题
程序代码:
#include<stdio.h> #define swap1(a, b) (a = a+b, b = a-b, a = a-b) int main(void) { int a = 6; int b = 7; swap1(a, a); printf("a = %d\n", a); return 0; }
最后结果a = 0.
执行swap(a, a)时,a值赋给宏中的a与b, 当执行a = a + b时,此时的b值为0。我这样说是否正确呢?