I wish to use gdb to print all array elements of allocated memory.
int main() {
int* p=(int*)malloc(7*sizeof(int));
for(size_t j=0;j<7;++j) {
p[j]=j;
}
return 0;
}
So I compiled this program with -g3, use gdb to start it, and set break
> print p@7
I expected with will print out 1-7, but the actual output was
$1 = {0x6160b0, 0x5, 0xff00000000, 0x615c60, 0x615c80, 0x615c20, 0x615c40}
Why my expectation!=actual result, anything wrong with my program?