1

Ok, this was a bit too much for me. How do you read these declarations?

char *(*(**myCBT[][10])())[];

Please note: I'm not specifically asking for this example but for a general rule of thumb if a beginner like me faces a tough puzzle like this.

Frank Vilea
  • 8,323
  • 20
  • 65
  • 86
  • http://www.cdecl.org/ Such declarations are a bit much for everyone. I doubt anyone can find a decent example where you would need that. – cnicutar Aug 16 '11 at 17:59
  • See e.g. http://ieng9.ucsd.edu/~cs30x/rt_lt.rule.html for "right-to-left" rule. – Paul R Aug 16 '11 at 18:00
  • 1
    possible duplicate of [Complex Declarations](http://stackoverflow.com/questions/1893013/complex-declarations) – Oliver Charlesworth Aug 16 '11 at 18:01
  • @cnicutar: not as trouble as this one but signal(3) had a tricky declaration to many people, these days it's typedef'ed (at least here in BSDs). – sidyll Aug 16 '11 at 18:05
  • @sidyll The declaration for a signal handler is short and sweet compared to an `array of arrays of pointers to pointers to functions`. – cnicutar Aug 16 '11 at 18:07
  • @cnicutar, for sure. I said that it's not that difficult, but its just a more real world example on where/how more complex declarations can be used. – sidyll Aug 16 '11 at 18:10
  • Possible Duplicate: http://stackoverflow.com/questions/859634/c-pointer-to-array-array-of-pointers-disambiguation – legends2k Jul 10 '13 at 11:21

2 Answers2

2

Use David Anderson's Clock wise spiral rule for reading such notations.

Alok Save
  • 202,538
  • 53
  • 430
  • 533
1

From cdecl:

declare myCBT as array of array 10 of pointer to pointer to function returning pointer to array of pointer to char

sergio
  • 68,819
  • 11
  • 102
  • 123