1

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?

Community
  • 1
  • 1
coder_neo
  • 23
  • 5

1 Answers1

2

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

Daniel Stevens
  • 750
  • 1
  • 9
  • 17