How to display a dynamically allocated array in the Visual Studio debugger?

Viewed 65360

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?

9 Answers

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.

In a watch window, add a comma after the name of the array, and the amount of items you want to be displayed.

Related