printf计算参数时是从右往左压栈的 & i++

时间:2023-01-09 22:33:51
#include <iostream>
#include
<string>
#include
<stdio.h>

using namespace std;

//printf计算参数时是从右往左压栈的
int test1()
{
cout
<< "test1";
return 1;
}

int test2()
{
cout
<< "test2 ";
return 2;
}

int main()
{
//printf计算参数时是从右往左压栈的
int i = 3;
printf(
"i = %d,i++ = %d\n",i,i++); // 注意: i=4 i++=3
int j = 3;
printf(
"j = %d,++j = %d\n",j,++j); // 注意: j=4 ++j=4

printf(
" %d,%d\n",test1(),test2()); // 显示: test2 test1 1,2
cout << test1() << " " << test2() << endl; // 也是显示: test2 test1 1 2
}