First (float**) is not a two dimensional array. It is a pointer to
pointer to float. It is often used in place of 2D arrays, but it still
isn't one. Some will even say that a C array declared like:
float x[10][10];
isn't a 2D array, either, but I will disagree.
How so? Surey, x[10] has type (float *)? I thought that in C,
x[i]
is purely syntactic sugar for *(x+i). Am I wrong?
It is *(x+i) but the compiler knows what it is applied to.
float x[10][10];
will allocate 100 contiguous float values, just like a Fortran array.
When you say x[i][j] it computes 10*i+j, scaled by sizeof(float) to
find the address of the array element. It will also do that for
*(*(x+i)+j) for an array with that declaration.
I believe the wording is that x[10] decays to (float*),
but x is not, and does not decay to, (float**). You can't,
for example, pass x to a subroutine with a float** dummy argument.
Re: weird code. ... never seen this kind of declaration ever. ... The variable data is a float pointer?...array of 16384 float objects. ... (comp.lang.c)
Re: new foo[42] ... > First question:... 42 type 'float' objects, and returns the address ... value in the pointer object 'foo'. ... The first form above dynamically allocates an array (which ... (comp.lang.cpp)
Re: weird code. ... The variable data is a float pointer?...array of 16384 float objects. ... We just write `sizeof *data' and the compiler (knowing what ... (comp.lang.c)
Re: char **argv & char *argv[] ..."pointer to pointer to char". ... >> pointer)) pointing to the first element of an array.... so we have to start adding more context.... type "pointer to char", rather than "array MISSING_SIZE of char". ... (comp.lang.c)
Re: multi dimensional arrays as one dimension array ... please - where does the standard say that such a conversion...Pointer conversion yields a pointer to the same object as ... exist only where there are array declarations.... (comp.lang.c)