Jump to content

Recommended Posts

Posted

People mainly use 2 ways of main...

int main()

{

//code

return 0;  //returns a value

}

 

void main()

{

//code

}

 

 

First of all main() is a function.

Functions have a type... int main() means that function main is of type integer and must return a value.

void main() means that function main does NOT return a value.

 

If you want your code to be portable, you should use the first way (int main()) because some compilers only support that way.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..