Page 1 of 1
Debugging in VC++ : Watching Part of an array
Posted: Sat Nov 13, 2004 6:56 pm
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 ?
Re: Debugging in VC++ : Watching Part of an array
Posted: Mon Nov 15, 2004 10:49 am
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
Posted: Sat Nov 27, 2004 8:17 pm
by Heartattack!
Oi,Pops,
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.
Posted: Wed Dec 01, 2004 6:58 am
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"

Posted: Wed Dec 01, 2004 9:48 am
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

Posted: Wed Dec 01, 2004 12:05 pm
by popel
Titir mia,
Who has told you that I use .NET ?

Posted: Wed Dec 01, 2004 8:41 pm
by Heartattack!
Well, you should.
