How to display a dynamically allocated array in the Visual Studio debugger?(如何在 Visual Studio 调试器中显示动态分配的数组?)
问题描述
如果您有一个静态分配的数组,Visual Studio 调试器可以轻松显示所有数组元素.但是,如果您有一个动态分配并由指针指向的数组,则当您单击 + 将其展开时,它只会显示该数组的第一个元素.有没有一种简单的方法可以告诉调试器,将此数据显示为类型为 Foo 且大小为 X 的数组?
If you have a statically allocated array, the Visual Studio debugger can easily display all of the array elements. However, if you have an array allocated dynamically and pointed to by a pointer, it will only display the first element of the array when you click the + to expand it. Is there an easy way to tell the debugger, show me this data as an array of type Foo and size X?
推荐答案
是的,很简单.说你有
char *a = new char[10];
在调试器中写入:
a,10
会像数组一样显示内容.
would show you the content as if it were an array.
这篇关于如何在 Visual Studio 调试器中显示动态分配的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Visual Studio 调试器中显示动态分配的数组


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01