Confused about declarations in C involving pointers ?

We know that in “C”, variable declaration involving functions and pointers at times gets quite confusing.
If you disagree please have a go at

declare x as const pointer to array 10 of pointer to function (int) returning const pointer to char

or

char *(*(**foo[][8])())[]; // decipher quickly please : )

It is certainly quite obtuse unless you are well versed with “right-left” rule.
Linux has this nice program cdecl which helps in figuring out where to put parentheses and where to put “const” and “volatile” modifiers in declarations. There is an online version of cdecl and like Detexfy I find it very useful and simple and hence sharing it here. If you are still itching your head with above examples, go an try your self on http://cdecl.org/

Advertisements
This entry was posted in Programming and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s