Watching a C++ array in Visual Studio [duplicate]
Asked Answered
B

2

18

I have declared an array as follows:

int *arr;

Is there any way in visual studio to watch all the elements of the array while debugging, rather than having to manually place watch for an element *(arr+1), *(arr+2) and so on.

Borne answered 4/2, 2011 at 21:51 Comment(1)
That is a pointer to int not an array!Chemoreceptor
G
28

If arr is a pointer to an array of ten integers, you can add "arr,10" to the watch window and when you expand it it will show the ten elements [obviously, you can replace the 10 with whatever the length of your array is].

Greenaway answered 4/2, 2011 at 21:57 Comment(1)
precisely what I was looking for. Thanks!Borne
D
5

You can do a memory window on that address - will show all the contents.

Dour answered 4/2, 2011 at 21:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.