C Exercise Example 47
100 cases of classic C language
Title: macro #define command Exercise 2.
Program Analysis: None.
Source Code:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include<stdio.h> #define exchange(a,b) { int t;t=a;a=b;b=t;}//注意放在一行里 int main() { int x=10; int y=20; printf("x=%d; y=%d\n",x,y); exchange(x,y); printf("x=%d; y=%d\n",x,y); return 0; }
The above example output is:
x=10; y=20 x=20; y=10