如何在 Visual Studio 调试器中显示动态分配的数组? [英] How to display a dynamically allocated array in the Visual Studio debugger?

查看:24
本文介绍了如何在 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 调试器中显示动态分配的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆