C isn’t that hard: void ( *( *f[] ) () ) ()

I just saw a picture today and think I’d appreciate explanations. So here is the picture:

some c code

I found this confusing and wondered if such codes are ever practical. I googled the picture and found another picture in this reddit entry, and here is that picture:

some interesting explanation

So this “reading spirally” is something valid? Is this how C compilers parse?
It’d be great if there are simpler explanations for this weird code.
Apart from all, can these kind of codes be useful? If so, where and when?

There is a question about “spiral rule”, but I’m not just asking about how it’s applied or how expressions are read with that rule. I’m questioning usage of such expressions and spiral rule’s validity as well. Regarding these, some nice answers are already posted.

13 Answers
13

Leave a Comment