|
|
Warp wrote:
> For instance, sizeof(table) is not the same as sizeof(int*).
Yes, OK.
> Also, you can't make 'table' "point" to
> somewhere else (because it's not a pointer).
I thought "table" was essentially a constant pointer to the first element. I
forgot about the sizeof() bit. I.e., that "int table[10]" made table be a
constant pointer to the first element of an anonymous block ten integers in
size.
> Here 'table' is also *not* a pointer, it's an array. Now you can allocate
> instances of that struct with malloc() and you will effectively have a
> heap-allocated array.
int* table = malloc(10*sizeof(int));
creates an anonymous array, then sets "table" as a pointer to the start of
it. So you can have heap-allocated arrays, you just can't give them names. :-)
Now we're picking nits, tho. You're right, C does have arrays.
--
Darren New, San Diego CA, USA (PST)
"We'd like you to back-port all the changes in 2.0
back to version 1.0."
"We've done that already. We call it 2.0."
Post a reply to this message
|
|