如何检查在 C 中首先计算哪个表达式?
How can I check which expression is evaluated first in C?
例如:
5*3 + 9*6
据我所知,根据编译器的类型,某些编译器首先评估 5*3
,而在其他编译器中,首先评估 9*6
。
C 中是否有函数或技术可以检查先评估哪个?
Is there a function in C or technique that can check which is evaluated first?
您可以定义一个函数来乘以数字并添加代码以产生一些输出。
int multiply(int n1, int n2)
{
printf("Computing %d*%d\n", n1, n2);
return n1*n2;
}
并使用该函数进行乘法而不是使用乘法运算符。
multiply(5, 3) + multiply(9, 6);
例如:
5*3 + 9*6
据我所知,根据编译器的类型,某些编译器首先评估 5*3
,而在其他编译器中,首先评估 9*6
。
C 中是否有函数或技术可以检查先评估哪个?
Is there a function in C or technique that can check which is evaluated first?
您可以定义一个函数来乘以数字并添加代码以产生一些输出。
int multiply(int n1, int n2)
{
printf("Computing %d*%d\n", n1, n2);
return n1*n2;
}
并使用该函数进行乘法而不是使用乘法运算符。
multiply(5, 3) + multiply(9, 6);