Hi!
arnuld schrieb:
if that is true then, is this right:
int* matrix[10]; /* an array of 10 pointers to ints */
Yes, correct. You should learn a bit about parsing tokens. Your array
definition is parsed into distinct "parts" (tokens):
"int" "*" "matrix" "[" "10" "]" ";"
and the compiler drops the white space (spaces, tabs, newlines). So the
following are all identical:
int*matrix[10];
int * matrix [ 10 ] ;
int* matrix
[
10
];
So don't be afraid of "int* matrix" and "int *matrix" doing something
different.
can't i write a replcement of author's 2nd example above ?
I can't think of one.
and what about these:
(int*) matrix[10]; /* ?? */
I took me a while to recognize it! This is valid syntax but it is not a
variable declaration. Instead it reads index "10" from the variable
"marix" (which needs to be declared before) and casts the result into
"int*" whereupon this result is discarded/dropped/ignored.
int (*) matrix[10]; /* ?? */
This is invalid syntax. So it has no meaning.
Frank