Whenever I look for what the brackets operator []
does, even in the tables that show all operators in C, it appears that it serves to access an element of an array. However, this is not always the case, for example in the case where the arrangement does not yet exist, that is, at creation time:
int main()
{
// nessa linha, eu tenho a certeza de que o colchetes não faz acesso a nada.
void *ptrArray[100];
// porém, nessa linha, eu sei que o colchetes faz o acesso ao 2º elemento do arranjo
ptrArray[1];
}
So since there's no mention anywhere about the operator []
at the time of creating arrangements, I assume he's not an operator in this case. Is that right?
How does the compiler differentiate? I believe the compiler recognizes the difference because it saw that there was a keyword of a primitive type or struct
before, in my case it is the keyword void
.
The return of the []
operator is always a pointer, right? So, at compile time, it's like void *ptrArray[100]
was void **ptrArray
, right?