Page 149 - C-Language
P. 149

int *(*func())();


        Find the identifier.


         int *(*func())();
                ^^^^


        "func is"


        Move right.


         int *(*func())();
                    ^^


        "func is function returning"

        Can't move right anymore because of the right parenthesis, so move left.


         int *(*func())();
               ^


        "func is function returning pointer to"


        Can't move left anymore because of the left parenthesis, so keep going right.


         int *(*func())();
                       ^^


        "func is function returning pointer to function returning"

        Can't move right anymore because we're out of symbols, so go left.


         int *(*func())();
             ^


        "func is function returning pointer to function returning pointer to"


        And finally, keep going left, because there's nothing left on the right.


         int *(*func())();
         ^^^


        "func is function returning pointer to function returning pointer to int".

        As you can see, this rule can be quite useful. You can also use it to sanity check yourself while
        you are creating declarations, and to give you a hint about where to put the next symbol and
        whether parentheses are required.


        Some declarations look much more complicated than they are due to array sizes and argument




        https://riptutorial.com/                                                                             125
   144   145   146   147   148   149   150   151   152   153   154