I am trying to use Visual Studio's debugging features more effectively; I certainly do not know all its ins and outs.

At the moment, I would like to quickly see the values of an array.

See the attached screenshot of the Watch Window.
The variable k is a global array of type double variables; during the present execution, it contains 5 entries.
I have stepped through the program into a sub-routine and would like to see the present values of k's entries.
If I add a watch (Cntrl-D, Q) for k, the address for k and its first entry only are shown.
To see the values of the other four entries, I had to manually add a watch for each entry: k[0], k[1], k[2], etc.
There must be an easier way to do this. I'd simply like to click on the variable in the Watch window, expand it, and view all the values of the array entries. Adding watches manually, especially for larger arrays, could get tedious.

Am I overlooking a setting in the IDE?

Any and all advice is appreciated.

Recommended Answers

All 6 Replies

The only way I know to do that is to move the cursor on the array name then an + will appear, select the + and it will show all array elements. You can even do that for linked lists, but only one node at a time. It doesn't work like that for pointers to arrays.

When in the debugger, did you already try to hover over a variable in the source with your mousepointer?

AD: Do you mean in the Watch Window? That is what I would like to do, and what I tried to do (see the image attached to my first post). It didn't expand to all the array elements.

ddanbe: Attached is another image. This one shows the mouse over the variable, and I tried to click on it, to make it expand, but didn't get any further.

That is what I meant. To expand it you normally see a + as AD mentioned.

This one shows the mouse over the variable, and I tried to click on it, to make it expand,

It won't expand if the variable is just a pointer because the debugger has no idea how many elements are in the array, or even if it is an array at all.

But if it's an array and not a pointer than click the + that's in the box just before the variable name.

AD: Do you mean in the Watch Window?


Okay, I have played around with it a little more.
The fact that the arrays are global seems to be affecting the behaviour. All arrays declared local to the function, or passed in as usual, behave as expected (i.e. - I can watch all entries as usual).

I am going to mark this thread "Solved" and move on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.