Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
能解释一下这个C输出吗?_C - Fatal编程技术网

能解释一下这个C输出吗?

能解释一下这个C输出吗?,c,C,可能重复: #包括 无效调用(int,int,int); int main(){ INTA=10; 调用(a,a++,a++); 返回0; } 无效调用(整数x,整数y,整数z){ printf(“x=%d y=%d z=%d\n”,x,y,z); } 这段代码在运行时给了我12 11 12的输出。有人能确切地解释一下这是怎么发生的吗?您的代码的行为是因为您在以下两种情况之间更改了a: 行为未定义,因为在两个序列点之间更改变量两次 c99 standard : 5.1.2.3 Program

可能重复:

#包括
无效调用(int,int,int);
int main(){
INTA=10;
调用(a,a++,a++);
返回0;
}
无效调用(整数x,整数y,整数z){
printf(“x=%d y=%d z=%d\n”,x,y,z);
}

这段代码在运行时给了我12 11 12的输出。有人能确切地解释一下这是怎么发生的吗?

您的代码的行为是因为您在以下两种情况之间更改了
a


行为未定义
,因为在两个序列点之间更改变量两次

c99 standard : 5.1.2.3 Program execution
二,

在这里,您将在两个序列点之间修改一个变量
a

c99 standard : 5.1.2.3 Program execution
扩展编辑:如果您已经知道这些概念并考虑到这一点,逗号运算符是一个序列点,因此它应该作为一个定义良好的
程序工作。那么您就错了
在函数调用中使用的是
逗号分隔符
而不是
逗号运算符

c99 standard : 5.1.2.3 Program execution
"Accessing a volatile object, modifying an object, modifying a file, or calling a function
that does any of those operations are all `side effects` which are changes in the state of
the `execution environment`. Evaluation of an expression may produce side effects. At
certain specified points in the execution sequence called `sequence points`, all side effects
of previous evaluations shall be complete and no side effects of subsequent evaluations
shall have taken place."