int main(){
int *a;
int b[3] = {1,2,3};
a = b;
int *c[3] = {a, b, 0};
int **d = c;
return 0;
}
While debugging the above code if you do:
(gdb) print b
$4 = {1, 2, 3}
that works.
(gdb) print a
$5 = (int *) 0x7fffffffe0f0
that works too, but in order to print a as an array you must do:
(gdb) print (int []) *a
$7 = {1}
and when you specify the size it gets better:
(gdb) print (int [3]) *a
$8 = {1, 2, 3}
The same goes for c and d:
(gdb) p c
$9 = {0x7fffffffe0f0, 0x7fffffffe0f0, 0x0}
(gdb) p (int*[3]) *d
$10 = {0x7fffffffe0f0, 0x7fffffffe0f0, 0x0}
(gdb)
And finally a very recently discovered short hand thanks to Jan Kratochvil:
(gdb) p *a@3
$11 = {1, 2, 3}
(gdb) p *d@3
$12 = {0x7fffffffe0f0, 0x7fffffffe0f0, 0x0}







