How to view the contents of a dynamically created array in xcode debugger (C++)?
int main(int argc, const char * argv[])
{
int *v;
int size;
cout << "Enter array size" << endl;
cin >> size;
v = new int [size];
for (int i=0; i<size; i++){
cin >> v [size];
}
// see array contents
return 0;
}
I want to view contents of v.
We didn't add some syntax in the expression parser like the gdb "@" syntax because we want to keep the language syntax as close to C/ObjC/C++ as possible. Instead, since the task you want to perform is "read some memory as an array of N elements of type T", you would do this using:
(lldb) memory read -t int -c `size` v
In general, -t tells the type, and -c the number of elements, and I'm using the fact that option values in back ticks are evaluated as expressions and the result substituted into the option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With