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

查看:384
本文介绍了如何显示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?

推荐答案

是的,很简单。
说你有

Yes, simple. say you have

char *a = new char[10];

写作中的调试器:

writing in the debugger:

a,10

会告诉你的内容就好像它是一个数组。

would show you the content as if it were an array.

这篇关于如何显示Visual Studio调试器动态分配的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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