1 Replies - 202 Views - Last Post: 01 September 2013 - 04:29 AM Rate Topic: -----

#1 Tycoonie259  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-September 13

Differences with return (0)?

Posted 01 September 2013 - 04:09 AM

Hey guys,

I recently started programming in C using C for dummies, and I noticed programs of that book always ended with
return (0)

Though I've seen
return 0
(without braces) too.

So is there a difference between:

return (0)
and
return 0
?



Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Differences with return (0)?

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: Differences with return (0)?

Posted 01 September 2013 - 04:29 AM

One is redundant, one is not. ;)/>

The return is a statement, not a function. Perhaps for this reason, parenthesis are not required.

Adding parenthesis is allowed. And, of course, for something like return (str+found); it makes some sense, because you want to explicitly evaluate before you return. However, it can lead to confusion, as return is NOT a function and shouldn't be treated like one.

This post has been edited by baavgai: 01 September 2013 - 04:30 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1