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

前端 未结 4 688
长情又很酷
长情又很酷 2021-02-19 00:04

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 vari

4条回答
  •  情话喂你
    2021-02-19 00:52

    The solution proposed only works with 1D arrays. But a 2D array that has fixed size in each row (seeing the first dimension as a row as in maths) can be allocated as a 1D array as follows:

    int ** a = new int * [n];
    int * b = new int [n*n];
    
    a[0] = &b[0];
    for (int i=1; i

    You can then use a as a matrix in your code and visualise using say b,100 if your matrix is 10 by 10.

提交回复
热议问题