Jichao Jichao - 1 year ago 195
C Question

Understanding some crazy C/C++ declarations


Possible Duplicate:

How to understand complicated function declarations?




Consider:

char (*(*x())[5])()


How do I dissect this expression?

I think it is a function which return an array of size 5, whose members are pointers to function which receive no input and return a char.

Am I right?

Answer Source

Search for "Right-left rule"

In your case, it should be:

         x          : x is a
         x()        : function
        *x()        : returning pointer to
       (*x())[5]    : a 5-element array of 
      *(*x())[5]    : pointer to
     (*(*x())[5])() : function
char (*(*x())[5])() : returning char
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download