Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see all elements of a two dimensional array in Visual Studio 2010?

I'm debugging my c++ code in Visual Studio 2010 and want to see the content of my array, say Q, which is 17x17. When I insert a breakpoint and try to debug, I see only the variable "Q". When I take it to the "Watch" screen and rename it to "Q,17", I see one level down.

But I want to see the other dimension,too. I can't write "Q,17,17". What is the proper command?

Thank you...

like image 473
Emre Turkoz Avatar asked May 10 '12 14:05

Emre Turkoz


People also ask

How do you access all elements in a 2D array?

An element in 2-dimensional array is accessed by using the subscripts. That is, row index and column index of the array. int x = a[1,1]; Console.

How do I view a 2D array in Visual Studio?

If you want to see the values organized in 2D in a more graphical way, you can try the Array Visualizer extension. It works fine with small multidimensional arrays. It is a free, open source extension which can be downloaded via MarketPlace. It is designed to display arrays while debugging an application.

How do you view 2D arrays?

Accessing 2D Array Elements In Java, when accessing the element from a 2D array using arr[first][second] , the first index can be thought of as the desired row, and the second index is used for the desired column. Just like 1D arrays, 2D arrays are indexed starting at 0 .

How do you find the total number of elements in a 2D array?

The total number of elements that can be stored in a multidimensional array can be calculated by multiplying the size of all the dimensions. For example: The array int x[10][20] can store total (10*20) = 200 elements. Similarly array int x[5][10][20] can store total (5*10*20) = 1000 elements.


1 Answers

You can't, at least not directly.

What you can do is put &array[0][0] in the memory window, and then resize it so the number of columns matches one row of array data.

Alternatively, you can put array[0],17 in the watch window, and then repeat it for array[1],17, etc.

Not the answer you were looking for perhaps, but the watch window, while pretty powerful, just can't do what you want.

like image 145
John Dibling Avatar answered Sep 19 '22 07:09

John Dibling