Debugging in VC++ : Watching Part of an array

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
popel
New poster
Posts: 33
Joined: Fri Mar 15, 2002 2:00 am
Location: Dhaka, Bangladesh
Contact:

Debugging in VC++ : Watching Part of an array

Post by popel »

suppose int xyz[10000] is an array.
and we are using IDE Visual C++ 6.0

during debugging we can add xyz to watch window, it will show the whole array, when expanded.
If the array is large, it becomes slow when expanded and debugging becomes tiresome.

So how to view part of the array, say we want to watch
xyz[5500] to xyz[5599] only during debugging. is their any way ?
μδ. ταηνιπ αλ αμιη

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Re: Debugging in VC++ : Watching Part of an array

Post by CDiMa »

popel wrote:suppose int xyz[10000] is an array.
and we are using IDE Visual C++ 6.0

during debugging we can add xyz to watch window, it will show the whole array, when expanded.
If the array is large, it becomes slow when expanded and debugging becomes tiresome.

So how to view part of the array, say we want to watch
xyz[5500] to xyz[5599] only during debugging. is their any way ?
Something along the line of:
[c]
*(int (*)[100]) &xyz[5500]
[/c]
works with gdb.

Ciao!!!

Claudio

Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Post by Heartattack! »

Oi,Pops, 8) 8)
This works:
&arr[10],5

Suppose arr[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

then &arr[10],5 will show the following:
&arr[10],5
[0]=11
[1]=12
[2]=13
[3]=14
[4]=15

You have to simply give the address followed by a coma and then the number of members to be viewed.

PS: I think this is a new feature of VC++.Net 2003. I don't know if it works on previous versions.
We will, We will BREAK LOOP!!!!

popel
New poster
Posts: 33
Joined: Fri Mar 15, 2002 2:00 am
Location: Dhaka, Bangladesh
Contact:

Post by popel »

xyz+5500,100
It seems it will work with VC++ 6.0, the debugger takes it but no effect.
casting the array to smaller size should work, but I couldn't make it work.

So I use the alternate way (its also casting)
[cpp]
int (*p)[100]; /* keeping this in code */
[/cpp]
during debugging when i need p = xyz+5500, makes it happen.

something like (int (*)[100])(xyz+5500) should also also work.... but I don't know why it says "missing operator" :-?
μδ. ταηνιπ αλ αμιη

Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Post by Heartattack! »

Try "&xyz[5500],100"
(without the quotes)
The debugger will show 100 elements with indexes numbered 0,1,2.....
Item with index 0 will be xyz[5500], index 1 will be xyz[5501] and so forth.

I haven't tried on VC++ 6 though. I only have .Net 2003. Can't wait for 2005 8) 8) 8) 8)
We will, We will BREAK LOOP!!!!

popel
New poster
Posts: 33
Joined: Fri Mar 15, 2002 2:00 am
Location: Dhaka, Bangladesh
Contact:

Post by popel »

Titir mia,
Who has told you that I use .NET ?

:roll:
μδ. ταηνιπ αλ αμιη

Heartattack!
New poster
Posts: 45
Joined: Fri Jan 16, 2004 7:02 pm
Location: CSE::BUET
Contact:

Post by Heartattack! »

Well, you should. :D :D
We will, We will BREAK LOOP!!!!

Post Reply

Return to “C++”