C - Complicated pointer declarations - help understanding
Posted
by Emmel
on Stack Overflow
See other posts from Stack Overflow
or by Emmel
Published on 2010-04-18T18:05:29Z
Indexed on
2010/04/18
18:13 UTC
Read the original article
Hit count: 417
In my burgeoning new self-education in the C language, I've come across a set of declarations that I do not understand how to read. I'd love for someone to break these down. I'll explain at the bottom where I got these examples from.
1.
char (*(*x())[])()
"x: function returning pointer to array[] of pointer to function returning char" - huh?
2.
char (*(*x[3])())[5]
"x: array[3] of pointer to function returning pointer to array[5] of char" - come again?
3.
char **argv
This I understand. "Pointer to pointer to char." But what I don't understand is -- what's the use case for a pointer to a pointer?
Follow-up question: does anyone every use declarations this complex or is this just academic fun on the part of the authors of the examples I got this from?
These examples are from section 5.12 of the K&R book. This is the first time I'm genuinely stumped by an explanation, in an otherwise well-written classic.
Thanks.
© Stack Overflow or respective owner