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

Adam Rosenfield picture Adam Rosenfield · Sep 16, 2008 · Viewed 57.6k times · Source

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?

Answer

shoosh picture shoosh · Sep 16, 2008

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.