c - Parenthesis surrounding return values -


quite in ansi c code can see parenthesis sorrounding single return value.

like this:-

int foo(int x) {   if (x)     return (-1);   else     return (0); } 

why use () around return value in cases? ideas? can see no reason that.

there isn't reason...it's old convention.

to save space, programmers final math in return line instead of on it's own line , parens ensure there make easier see single statement returned, this:

return (x+i*2); 

instead of

int y = x+i*2; return y; 

the parenthesis became habit , stuck.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -