Created
June 7, 2010 02:18
-
-
Save mrluanma/428137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Description: | |
The "beauty" of C macro. | |
*/ | |
#include <stdio.h> | |
#define PRODUCT(x) (x * x) | |
int main(int argc, char**argv) | |
{ | |
int i = 3, j, k; | |
/* | |
j is 9. | |
*/ | |
j = PRODUCT(i++); | |
/* | |
k is 49. | |
*/ | |
k = PRODUCT(++i); | |
printf("%d %d\n", j, k); | |
return 0; | |
} | |
/* | |
$ cpp product.c | tail -18 | |
int main(int argc, char**argv) | |
{ | |
int i = 3, j, k; | |
j = (i++ * i++); | |
k = (++i * ++i); | |
printf("%d %d\n", j, k); | |
return 0; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment