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

C11 > FIOC

Name: Anonymous 2012-06-08 3:42

The following is valid C11 code.
You jelly FIOCfags?


#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv){
    int a, b;

    if(argc < 3){
        fprintf(stderr, "Usage: %s n1 n2\n", argv[0]);
        return 1;
    }

    a = atoi(argv[1]);
    b = atoi(argv[2]);

    a, b = b, a;

    printf("%d, %d\n", a, b);

    return 0;
}

Name: Anonymous 2012-06-08 4:02

a, b = b, a;

What is this supposed to do? It seems like a kewl idiom for swapping the values of a and b, but the last time I checked "," had precedence over "=". Is this actually new in C11?

Name: 3 2012-06-08 4:04

* "=" had precedence of ","

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