- 论坛徽章:
- 0
|
本帖最后由 bingbuidea 于 2011-03-24 10:46 编辑
- #include <stdio.h>
- #define FUNC(x) ((x)*(x)*(x))
- int func(int x)
- {
- return x*x*x;
- }
- int main(void)
- {
- //int i=1;
- //int j=1;
- static int j=1;
- static int i=1;/*static is different from non-static*/
-
- printf("%d,%d,%d,%d\n",i++,i++,++i,++i);
- printf("%d \n",func(i++));
- printf("%d \n",func(++i));
- printf("%d \n",FUNC(j++));
- printf("%d \n",FUNC(++j));
- return 0;
- }
复制代码 /***************i,j is not static *****************/
/*Linux gcc result:
4,3,5,5
125
343
1
252
*/
/*Visual C++ 6.0 result:
3,3,3,2
125
343
1
252
*/
/*****************************************/
/***************i,j is static *****************/
/*Linux gcc result:
4,3,2,2
125
343
1
60
*/
/*Visual C++ 6.0 result:
3,3,3,2
125
343
1
252
*/
/*****************************************/ |
|