为了检查评估顺序,我们将使用一个简单的程序。这里传递了一些参数。从输出中我们可以看到它们是如何被评估的。
示例代码#include<stdio.h>void test_function(int x, int y, int z) { printf("the value of x: %d
", x); printf("the value of y: %d
", y); printf("the value of z: %d
", z);}main() { int a = 10; test_function(a++, a++, a++);}
输出the value of x: 12the value of y: 11the value of z: 10
从这个输出中我们可以很容易地理解评估序列。首先取 z,所以它是 10,然后取 y,所以它是 11,最后取 x。所以值为 12。
以上就是c语言中的函数参数的评估顺序是什么?的详细内容。
