我试图将地址的值存储在非指针int变量中,当我尝试转换它时,我得到编译错误"无效转换从'int*'到'int'"这是我正在使用的代码:
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
vector<int> test;
int main() {
int *ip;
int pointervalue = 50;
int thatvalue = 1;
ip = &pointervalue;
thatvalue = ip;
cout << ip << endl;
test.push_back(thatvalue);
cout << test[0] << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 根据MSDN,RECT和RECTL是相同的结构.它们之间是否存在任何差异?如果不是,那么它们是否只有一个而不是一个?
我试图通过将一个int转换为const CHAR*来获取一个消息框来显示变量的地址,我目前的功能失调尝试看起来像这样:
#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;
}
Run Code Online (Sandbox Code Playgroud)
dos框打印2293616,消息框打印"9 |"