Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C macro templace abuse

Name: Anonymous 2012-06-14 1:13

#include <stdio.h>
#define swap(T,x,y) ({T tmp = (x); (x) = (y); (y) = tmp;})

int main() {
    int x = 2, y = 5;

    swap(int, x, y);
    printf("x = %d, y = %d", x, y); //x = 5, y = 2
    return 0;
}


Is this bad practice?

Name: Anonymous 2012-06-14 3:03

>>7
or maybe even swapsperm

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List