我收到“访问冲突读取位置0x0000000000000008”。与此代码:结构
main.xcpp
Penguin::Game game;
game.memory = {};
game.memory.permanentSize = 1024*64;
game.memory.permanent = VirtualAlloc(0, game.memory.permanentSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
game.Start();
game.Start()
input = (Input *)memory.permanent;
*input = {}; // << Access violation reading location.
游戏结构
struct Game
{
struct Memory
{
uint64 permanentSize;
void *permanent;
};
Memory memory;
Input *input;
void Start();
};
不过。如果我尝试:
int *i = (int *)memory.permanent;
*i = 10;
它的工作原理。
我在做什么错了?
你有一个调试器,学习如何使用它! –