It is an unconditional, I-know-what-i'm-doing kind of
cast.
To help the explanation, I'm going to change the subscripts some:
char t[4][3], *p = (char*)t;
By itself, t degenerates into a 'pointer to an array of 3 chars' (char[3]).
The
number of arrays of three chars doesn't matter (even though there are four).
So t is the address of (the first char) of (the first array) of (the array of arrays).
The cast, (char*), tells the compiler to forget all that information and instead pretend that address is to a single character (or an array of them -- again, it doesn't matter how many there are).
Just so you know, that line of code bothers people on several levels, but mainly because it mixes pointer type declarations with non-pointer type declarations, which is easily misread.
A good rule of thumb is to keep declarations of different types to one type per line:
1 2
|
int x, y, z;
float q, p;
|
Additionally, keep
each pointer declaration to it's
own line:
Rewriting the above, you get:
1 2
|
char t[3][3];
char * p = &(t[0][0]);
|
Hope this helps.