I was going through k&r complicated declarations part.I got doubt about this particular declaration.
char(*(*x[3])())[5]
Why cant it be
char[5] (*(*x[3])())
And can this declaration be legal?
int* (*(*x)())[2];
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to the precedence of operators and applying the spiral rule,
is equivalent to
But in,
the array subscript should be at the end of the declaration, thus resulting in a syntax error. You’ll bump into
nothingwhen you apply spiral rule to this.Also,
is perfectly legal and its declaration can be stated as
Check out the Java applet which can help you decode complicated declarations and also read these articles of how to form complicated declarations.
@Steve Jessop’s comment also seems plausible as to why the
[]go at the end.