#include<iostream>
using namespace std;
struct node{
int data;
node* l,*r;
};
int main()
{
node* n1 = new node;
cout<<(n1->l);
return 0;
}
在上面的代碼中,我沒有初始化結構資料 l 和 r。所以現在存盤的地址n1->l是CDCDCDCD. 現在,如果我想查看存盤在該地址中的值,如何在不將地址存盤在變數中的情況下查看該值。
uj5u.com熱心網友回復:
通常,您可以將任何整數轉換為指標,風險自負。
node* my_ptr = (node*)0xDEADBEEF; // Casting to a pointer
node my_node = *(node*)0xDEADBEEF; // Casting to a pointer and dereferencing
第二行是我相信你想要做的“不將地址存盤在變數中”。然而,這只是在特定的背景關系中有用,例如 DLL 注入。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/430743.html
上一篇:C通過參考傳遞的誤解
下一篇:無法修改C 陣列中的字串
