C程序设计语言 (第二版) 练习 4-14
练习 4-14 定义宏swap(t, x, y)以交换t类型的两个参数。(使用程序块结构会对你有所帮助。)
注意:代码在win32控制台运行,在不同的IDE环境下,有部分可能需要变更。
IDE工具:Visual Studio 2010
代码块:
#include <stdio.h>
#include <stdlib.h>#define swap(t, x, y) {t temp; temp = x; x = y; y = temp;}int main(){int x = 2;int y = 3;swap(int, x, y);printf("x = %d, y = %d\n", x, y);system("pause");return 0;
}