Reputation: 409
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.
Upvotes: 10
Views: 11086
Reputation: 49
There is a better answer over at another thread.
https://stackoverflow.com/a/26303375/767039
I think this is easier to use and remember.
Upvotes: 0
Reputation: 27110
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.
Upvotes: 16