Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/20/03 16:56
Read: times


 
#61136 - RE: kinda on subject, but it is weekend re C
Responding to: ???'s previous message
As C compilers require a pretty rigid structure for most of the input, the how come the following 4 are frequently interchangeable:
return Ralph
return (Ralph)
return Ralph;
return (Ralph);


Compilers that do not whine about the first two examples do not strictly conform to the standards, since the "return" statement requires a terminating semicolon. The only C statement that does not require a terminating semicolon is the compound statement (or block), which is delimited by braces ({ }).

As for the second two examples, another rule for C statements is that "control" expressions appearing in conditional and iterative statements be enclosed in parentheses. Since "return" is neither a conditional nor iterative statement, its syntax is "return expression ;". For expression usage in this context, the purpose of the optional parentheses is simply to delimit the enclosed expression for grouping purposes, either to defeat the default precedence of operators or make the code more readable.


List of 16 messages in thread
TopicAuthorDate
kinda on subject, but it is weekend re C            01/01/70 00:00      
   RE: kinda on subject, but it is weekend re C            01/01/70 00:00      
   RE: kinda on subject, but it is weekend re C            01/01/70 00:00      
   RE: kinda on subject, but it is weekend re C            01/01/70 00:00      
      RE: semicolons            01/01/70 00:00      
         RE: semicolons            01/01/70 00:00      
            RE: semicolons            01/01/70 00:00      
               RE: semicolons            01/01/70 00:00      
                  RE: semicolons            01/01/70 00:00      
                     RE: semicolons            01/01/70 00:00      
                        RE: semicolons            01/01/70 00:00      
                     RE: semicolons            01/01/70 00:00      
            RE: semicolons            01/01/70 00:00      
               RE: semicolons            01/01/70 00:00      
                  Fatal assumptions            01/01/70 00:00      
                     RE: Fatal assumptions            01/01/70 00:00      

Back to Subject List