关于函数形参入栈顺序问题
大多编译器是按从右到左的顺序进栈,
如果形参为int时,b的地址比a大,但为字符时,a的地址比b大,为什么?
#include <iostream>
#include <stdlib.h>
using namespace std;
int v1(int a,int b)
{
cout <<"The address of int a is:"<<(int)&a<<endl;
cout <<"The address of int b is:"<<(int)&b<<endl;
return 0;
}
int v2(char a,char b)
{
cout <<"The address of char a is:"<<(int)&a<<endl;
cout <<"The address of char b is:"<<(int)&b<<endl;
return 0;
}
int main()
{
v1(2,10);
v2(2,10);
getchar();
return 0;
}