Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable two dimensional array printing "subscript of pointer to incomplete type" when accessed

Tags:

I am declaring a two dimensional array as such:

char arr[10][10]; arr[0][0] = 'X'; 

Now I print in debugger;

(lldb) po arr[0][0] 'X' 

Awesome!! No problem.

Now I am declaring a two dimensional array as such:

int col = 10; int row = 10; char arr[row][col]; arr[0][0] = 'X'; 

Now I print in debugger;

(lldb) po arr[0][0] error: subscript of pointer to incomplete type 'char []' error: 1 errors parsing expression 

Why??

like image 438
etayluz Avatar asked Jan 22 '16 16:01

etayluz


1 Answers

The debugger doesn't know exactly how big the array is, so you need to apply a cast:

(gdb) p ((char (*)[10])arr)[0][0] $2 = 88 'X' 
like image 173
dbush Avatar answered Oct 02 '22 07:10

dbush