C/C++宏定义交换两个值

#define SWAP(t,a,b)           \
do{                           \
t c = a;                      \    
a = b;                        \
b = c;                        \
}while(0);     



void main()
{
    int a=1,b=2;
    SWAP(int,a,b);  
}

猜你喜欢

转载自www.cnblogs.com/judes/p/10230410.html