Patryk
Patryk

Reputation: 24092

How to see what are the contents of dynamically allocated array while debugging in VS 2010?

I would like to be able to see the contents of dynamically allocated array while debugging in Visual Studio 2010. One can easily watch what's inside the statically allocated array but when it comes to dynamical allocation only the address of first element can be seen in debug mode.

Is there an option to preview these contents ? (other than making an array with constant size and assigning all dynamical allocated contents to it)

Upvotes: 1

Views: 1948

Answers (2)

dima1st
dima1st

Reputation: 51

You can use memory view window during debug (menu debug->windows->memory->...). Type "ptr" (without quotes) there and you will see actual memory image. While you step in debugger every change occured to the memory will be marked in red.

Upvotes: 2

ZarakiKenpachi
ZarakiKenpachi

Reputation: 457

It is quite simple, F.e. you have:

char* ptr = new char[10];

Then if you write in debugger:

ptr,10

it will show you content as if it were static array.

Upvotes: 3

Related Questions