Viewing all elements of dynamically allocated arrays In VC++

Joined
Jan 29, 2010
Messages
1
Reaction score
0
Hi all,
i have developed a program to view elements of dynamically allocated arrays in VC++.Any suggestions are welcomed.

Normally when you allocate an array dynamically, and then look at the variable in the watch window you can only see the first element. But if you want to view the entire array just type the <variable-name>, <number-of-elements-to-view>.

Example

void main( void )
{
const int SIZE = 10;
int *intArray = 0;

intArray = (int *)malloc( sizeof( int ) * SIZE ) ;

for( int x = 0; x < SIZE; x++ )
{
intArray[x] = 10 + x;
}

return 0; // put a break point here, so that control stops here and
// we can see the "intArray" contents in "Watch" window
}
Watch Window: Debug -> Windows -> Watch ->

to see intArray in the watch window type

intArray, 10

and now we can see all the 10 elements of "intArray" in watch windows.
Thanks
Eliza
http://bit.ly/d4N9QL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top