例如:
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);
关于c - 如何检查 C 中首先计算哪个表达式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38627476/