我試圖得到一個消息通過鑄造一個int到一個const char *顯示變量的地址,我目前不正常的嘗試看起來是這樣的:如何在消息箱中使用int字符串?
#include <cstdlib>
#include <iostream>
#include <windows.h>
int main()
{
int *ip;
int pointervalue = 1337;
int thatvalue = 1;
ip = &pointervalue;
thatvalue = (int)ip;
std::cout<<thatvalue<<std::endl;
MessageBox (NULL, (const char*)thatvalue, NULL, NULL);
return 0;
}
DOS窗口打印2293616,在MessageBox打印「9 |」
出於好奇,爲什麼'hex'? – Cornstalks
由於指針通常以十六進制格式查看。 –
@RyanGuthrie:啊,我錯過了那個問題中的thatvalue是指針的值。說得通。 – Cornstalks