如何打印用戶輸入的地址?這種方式不起作用。打印用戶在C++中鍵入的內存地址的內容
這是代碼。謝謝。
#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);
}
對不起,我不是很清楚:
什麼程序必須做到: 要求輸入一個整數,從這些整數打印內存地址,請鍵入上面印着的內存地址,打印該內存地址的內容,並確認該地址是否有第一步輸入的號碼。
所有在一個運行時。先謝謝你。
啊,我很抱歉,我不明白你的要求第一時間,所以我的回答根本不是你在找什麼:) – AkiRoss 2013-04-25 23:48:53