Mega Code Archive

 
Categories / C / Development
 

Macro to substitude values etc

#include <stdio.h> #define swap(a, b) a ^= b ^= a ^= b; int main(void) { char one = 'a', two = 'b'; /* one = a, two = 'b' */ printf("before : %c %c\n", one, two); swap(one, two); /* one = 'b', two = a */ printf("after : %c %c\n", one, two); return 0; }