在 Visual C++ 中查看分配为 char 的内存位置上的整数2008调试器

发布于 2024-12-25 11:32:57 字数 139 浏览 3 评论 0原文

我正在使用 Visual C++ 2008 来编写和调试我的项目。我有一个 char* 指针。我想在调试器中以整数形式查看从指针开始的 4 个字节。我该怎么做?我想到了 (int)(*pointer) 但恐怕它只会简单地获取指针指向的 1 字节值并将其转换为整数。

I'm using Visual C++ 2008 to write and debug my project. I have a char* pointer. I want to view 4 bytes starting at my pointer as an integer in the debugger. How do I do it? (int)(*pointer) comes to mind but I'm afraid it will simply take the 1-byte value pointed to by pointer and convert it to an integer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原野 2025-01-01 11:32:57

您必须将指针转换为所需的指针类型,然后取消引用,如下所示:

*(int*)(pointer)

这在 GDB 中有效,尽管我认为它在其他调试器中也类似。

You have to cast your pointer to the desired pointer type and then dereference, like so:

*(int*)(pointer)

This works in GDB, though I imagine it's similar in other debuggers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文