Macros

Macro to swap any two variable int, char, float, struct etc..
/* Generic Swap macro*/
#define swap (a, b, type) {type t = a; a = b; b = t; }

Call the macro like this:
swap(a,b,int)
swap(a,b,str)

Leave a Reply

Your email address will not be published. Required fields are marked *