#include<iostream>
using namespace std;
void f(int *p,int *q)
{
p++;
*q=*q+1;
}
int main() {
int m=1,n=2,*r=&m;
f(r,&n);
cout<<m<<","<<n;
return 0;
} 程序运行后的输出结果是()
#include<iostream>
using namespace std;
void f(int *p, int *q)
{
cout << "函数中自增前p的地址:" << p << endl;
p++;
cout << "*p" << *p << endl;
cout << "函数中自增后p的地址:" << p << endl;
*q = *q + 1;
}
int main()
{
int m = 1, n = 2, *r = &m;
cout << "调用前r的地址:" << r << endl;
f(r, &n);
cout << "调用后r的地址:" << r << endl;
cout << m << "\t" << n << endl;
cout << endl;
r++;
cout << *r << endl;
system("pause");
return 0;
}
运行结果: 调用前r的地址:003EFAC8
函数中自增前p的地址:003EFAC8
*p-858993460
函数中自增后p的地址:003EFACC
调用后r的地址:003EFAC8
1 3
-858993460
请按任意键继续. . .