|
Swap using Macros
This example shows swapping two numbers using macros.
04 | #define swap_macro(a,b) a=a+b;b=a-b;a=a-b; |
06 | int swap( int a, int b){ |
08 | printf ( "inside swap x:%d y:%d\n" ,a,b); |
15 | printf ( "x:%d y:%d\n" ,x,y); |
20 | printf ( "x:%d y:%d\n" ,x,y); |
|
It gives the following output,
x:8 y:2
inside swap x:2 y:8
x:8 y:2
|
|