Page 148 - C-Language
P. 148
Look at the symbols on the right of the identifier. If, say, you find () there, then you know that this
is the declaration for a function. So you would then have "identifier is function returning". Or if you
found a [] there, you would say "identifier is array of". Continue right until you run out of symbols
OR hit a right parenthesis ). (If you hit a left parenthesis (, that's the beginning of a () symbol,
even if there is stuff in between the parentheses. More on that below.)
STEP 3
Look at the symbols to the left of the identifier. If it is not one of our symbols above (say,
something like "int"), just say it. Otherwise, translate it into English using that table above. Keep
going left until you run out of symbols OR hit a left parenthesis (.
Now repeat steps 2 and 3 until you've formed your declaration.
Here are some examples:
int *p[];
First, find identifier:
int *p[];
^
"p is"
Now, move right until out of symbols or right parenthesis hit.
int *p[];
^^
"p is array of"
Can't move right anymore (out of symbols), so move left and find:
int *p[];
^
"p is array of pointer to"
Keep going left and find:
int *p[];
^^^
"p is array of pointer to int".
(or "p is an array where each element is of type pointer to int")
Another example:
https://riptutorial.com/ 124

