In the C programming language, it is possible to omit a code block in the case of a single statement, for example:
if(1) exit();
Now, does this only apply to conditionals ?
Why is this not valid in the case of functions:
void f(int a) exit();
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.
It’s a feature of C syntax. In BNF, a function definition is something like
while a statement is
(simplifying to allow intermixed declarations and statements, which C++ allows but C doesn’t), and an
ifstatement isomitting the
elsepart for now.The reason for this is that otherwise, you could write the function
as
but the latter syntax is already in use to denote a declaration.