c - 怎么答案是36?

标签 c

Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)

main()
{
   int a=5;
   a= a++ + ++a + ++a + a++ + a++;
   printf("%d",a);
}

最佳答案

这没有定义。

您可以找到 C 标准 2005 年 5 月 6 日起的委员会草案 here (pdf)

请参阅6.5 表达式部分:

2 Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.

和示例:

71) This paragraph renders undefined statement expressions such as

i = ++i + 1;

a[i++] = i;

关于c - 怎么答案是36?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2935009/

相关文章:

java - 以编程方式从内置摄像头捕获视频

c++ - C/C++ 内联汇编不正确的操作数类型

c - 如何区分服务器发出的两个不同的SIGUSR2信号?

无法捕获 if 语句中的撇号

c - C 程序的错误和警告

c++ - 不带循环和内置函数的字符串长度

c - X11 编程 : Get notified if new window appeared?

c - fscanf() 跨不同编译器的不一致行为(消耗尾随空字符)

c - 使用 getchar();定义多个变量

C通过函数传递值会更改函数中的值