View array in Visual Studio debugger?


Question

Is it possible to view an array in the Visual Studio debugger? QuickWatch only shows the first element of the array.

1
228
6/9/2009 9:15:04 PM

Accepted Answer

You can try this nice little trick for C++. Take the expression which gives you the array and then append a comma and the number of elements you want to see. Expanding that value will show you elements 0-(N-1) where N is the number you add after the comma.

For example if pArray is the array, type pArray,10 in the watch window.

545
9/18/2012 1:22:42 PM

If you have a large array and only want to see a subsection of the array you can type this into the watch window;

ptr+100,10

to show a list of the 10 elements starting at ptr[100]. Beware that the displayed array subscripts will start at [0], so you will have to remember that ptr[0] is really ptr[100] and ptr[1] is ptr[101] etc.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon