4 Replies - 586 Views - Last Post: 09 January 2013 - 09:07 AM Rate Topic: -----

#1 AhmerjavedC++  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 253
  • Joined: 02-October 09

Whats the difference between int main and void main?

Posted 09 January 2013 - 08:43 AM

Hi,

I am fairly new to C++ but i would like to know the difference between Int Main and Void Main. I know those are functions but whats the difference

Thanks,
Ahmer
Is This A Good Question/Topic? 0
  • +

Replies To: Whats the difference between int main and void main?

#2 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 665
  • View blog
  • Posts: 2,296
  • Joined: 31-December 10

Re: Whats the difference between int main and void main?

Posted 09 January 2013 - 09:03 AM

One is standard the other isn't. Just stick with int main().
Was This Post Helpful? 2
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: Whats the difference between int main and void main?

Posted 09 January 2013 - 09:04 AM

int main will return an integer, void main will not. You should use the int version, and return 0 when the program executes successfully. That will tell the system as much, and it'll interpret any other value (like 1) as if an error has occurred during the program execution.
Was This Post Helpful? 2
  • +
  • -

#4 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 665
  • View blog
  • Posts: 2,296
  • Joined: 31-December 10

Re: Whats the difference between int main and void main?

Posted 09 January 2013 - 09:06 AM

Technically speaking, in C++, a return 0 from main is not required, if it is omitted, the compiler will put it there for you.
Was This Post Helpful? 1
  • +
  • -

#5 AhmerjavedC++  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 253
  • Joined: 02-October 09

Re: Whats the difference between int main and void main?

Posted 09 January 2013 - 09:07 AM

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1