Viewing dynamic array variable values in Xcode
I have a dynamic array of pointers for a struct.
struct item {
unsigned long code; //1 - 2^32
unsigned short date; //0 - (13*365+4-31)+1
unsigned char place; //1 - 200
unsigned short amount; //0 - 10000
unsigned short price; //0 - 50000
};
count = getSizeFromSomewhere();
item ** x=new item * [count]; //real used array
item * y[10]; //just for example
When I debug this code in Xcode, I can observe each element of the y array and the corresponding structure values of the element. But in array x, I cannot observe anything other than the first element (and the corresponding element structure).
Is there a way to see x as an array of pointers (as I did with y ).
+1
source to share
1 answer
Since memory for 'x' is dynamically allocated at compile time, it is unaware of the size of the array. But 'y' is allocated on the stack and it can easily determine its size. Because of this, you cannot watch "x", since you can watch "y". The easiest way to observe "x" is to add hours for x [i], where i = 0..count-1
+2
source to share