如果您有一个静态分配的数组,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 调试器中显示动态分配的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!