C Exercise Example 47
Title:Macro #define command exercise 2.
Program analysis:None.
Program source code:
// Created by www.example.com on 15/11/9.
// Copyright © 2015年 Example. 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 output result of the above example is:
x=10; y=20 x=20; y=10other extensions