c - For an X dimensional array where X is greater than 1,is only the first dimension optional,rest are mandatory? -


i trying head around since new c can't imagine how @ or beyond 3d arrays.i know have mention size of static 1d arrays,but in 2d arrays,the first dimension optional in declaration in:

int arr[][2]={{2,3},{4,8},{5,3}}; 

but x dimensional arrays?are following ok or first dimension optional mentioned , rest necessary?

 int arr[][][2]= blah blah;  int arr[][][][8]= blah blah; 

i know in above case of 2d array,the second dimension necessary perform pointer arithmetic using arr,but can't imagine how things or wouldn't work out array dimension greater 2.

only 1 can left blank. in order know how particular value, needs able compute offset of first value.

for example:

char array[][3]

the system knows go 3 bytes (assuming 1-byte chars) * first part of array index + 1 each part in second.

char array[][2][3]

the system knows go 6 bytes (2*3) bytes * first part of array index + 3 * second part + 1 * last part.

if 2 weren't there, couldn't figure out how far offset based on value of first index.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -