最近更新系统到64位 , 程序跑的不对
//获取参数列表中的所有参数,并打印
void PrintInt(int cnt, …)
{
int num = sizeof(int);
int x = 5;
int numaddr = sizeof(&x);
int *temp = &cnt;
temp += numaddr/num;
for (int i = 0; i < cnt; ++i)
{
int num = *temp;
qDebug() << num << ” \n”;
temp+= 2;
}
}
int main(void)
{
int a = 1;
int b = 3;
int c = 3;
int d = 4;
PrintInt(4, a, b, c, d);
return 0;
}
由于整数地址变为8字节, 而整数类型依然是4个字节, 指针++时只加了4个字节导致参数错误