Search code examples
c++arrayscodelite

How to add debug watch for dynamically allocated array in CodeLite?


I would like to check the content of elements in array, while debugging my program. But when I add watch for dynamically allocated array all I can see is address for pointer?

enter image description here

Is there a way to watch the content of dynamically allocated array? I went through the below post, but solution didn't seem to work for CodeLite. I guess its because of different debugger.

How to display a dynamically allocated array in the Visual Studio debugger?


Solution

  • I've had some success using a casting style syntax for the watch value:

    (int[10]*)a
    

    This shows all array values once expanded in the watch window. The declaration of a in the code was:

    int *a = new int[10];
    

    Here is the watch window:

    enter image description here