如何打印用户输入的地址?这种方式行不通。
这是代码。谢谢。
#include <iostream>
using namespace std;
int main()
{
int num = 123456;
int *addr = #
cout << "Var: num, address: " << &num << ", has: " << num << endl
<< "Var: *addr, address: " << &addr << ", has: " << addr << endl
<< "Printing value of num using the pointer *addr: " << *addr << endl;
int addr_user;
cout << "Type the memory address: "; cin >> addr_user;
int *p_addr_user = (int *)addr_user;
cout << "The address given (" << addr_user << ") has: " << *p_addr_user << endl;
return( 0 );
}
对不起,我不是很清楚:
程序必须做什么:要求输入一个整数,从这些整数中打印内存地址,要求输入上面打印的内存地址,打印该内存地址的内容并确认该地址是否具有在步骤一中输入的数字。
一站式运行。先感谢您。