Forcing VC++ Debugger to Display Pointers as Arrays

· by Steve · Read in about 2 min · (222 Words)

I’m going to risk being called a dunce for not picking up on this until now, because I think there are probably other people with this annoying problem too. When you’re debugging in VC++, by default raw pointers only display a single item when you expand them, like this:

Now, if you know this pointer is actually a series of items and not just one, you really want to inspect them all - you can add array indices (pFoo[n]) but this is awkward if you want to browse rather than cherry-pick single items. I’ve sometimes used the ‘memory’ view to get around this, which is especially useful if you’re looking at an array of bytes, but arrays of floating point values aren’t that readable via the memory view.

The way to force VC++ to display raw pointers as arrays is to add ‘,n’ to the end of the watch expression, like this:

And if you want to skip a bunch of items, just use pointer arithmetic as usual, such as (pFoo + 50),100 showing items 50-150.

If you knew this already and think I’m a muppet for only just figuring this out, bully for you (although why didn’t you tell me, you bastard? 😉 ). I’m hoping to help the poor saps like me who have found this clunky in the past.