code understanding help

Terry Tree terry.tree at gmail.com
Sun Apr 3 09:37:42 PDT 2005


I'm trying to go through a book on programming in C and I'm having
problem understanding the second example in the book.

$cat 2.c 

#define PRINTX printf("%d\n", x);

int
main(int argc, char *argv[])
{
    int x = 2, y, z;

    x *= 3 + 2; PRINTX;
    x *= y = z = 4; PRINTX; // the output makes no sense
    x = y == z; PRINTX;
    x == (y = z); PRINTX;
}

Looking at line x *= y = z = 4; from my point of view the output
should be 8 but it is 40.





More information about the Users mailing list