Vs2010 C ++ viewing debug content pointers

I am working in Vs2010 C ++ with 2D arrays. I started with a 1D pointer and used the [] operation as follows:

class CMatrix { void clear(); public: int nRows; int nCols; short * MyMat; CMatrix(); CMatrix(int r,int c); ~CMatrix(void); void SetMatrix(int r,int c); short * operator[] (const int row) { return MyMat + (row*nCols); } }; 

I do not mind changing the 2D pointer.

However, my problem is with debugging. Since I use pointers, I do not see the contents of arrays.

Are there any other options?

I prefer not to use a vector.

+4
source share
2 answers

One way is to use the Memory viewer. During debugging (when stopping at a breakpoint), go to the Debug menu> Windows > Memory > Memory 1 . get memory viewer. Then enter the memory address (copy the value from the pointer) so that you can view the memory around this area of ​​your program memory.

When you right-click on a memory viewer, you can choose how you want to view data (like ANSI, like 4 integers, as 2 byte integers, like float, bla bla ...)

You can also use the Watch window during debugging. just use the pointer as an array (for example, if your pointer is char * t , the syntax t[0] will give your data with the specified pointer t

+9
source

In the QuickWatch window, you can enter the name of the pointer variable, followed by a comma, and the number of array indices you want to view, for example. MyMat, 10 .

+8
source

All Articles