regarding main function

Feb 15, 2013 at 4:58am
what is the use of 'int' in the command 'int main ()'?
Feb 15, 2013 at 5:36am
it's the return type. When you have
int main()
{
return 0;
}
It's basically a function that takes in no parameters and returns the integer 0;
Feb 15, 2013 at 6:25am
just that you don't need to write return 0; or any other integer value
Feb 15, 2013 at 6:39am
The int returned by main() is a way for a program to return a value to "the system" that invokes it. On systems that doesn't provide such a facility the return value is ignored...
http://www.stroustrup.com/bs_faq2.html#void-main
Feb 15, 2013 at 10:39am
On the command line this return code can be found in the environment variable ERRORLEVEL.
In the Powershell it's the variable $LastExitCode.

1
2
void main(){
}

works with most compilers / libraries, too.
Feb 15, 2013 at 11:01am
1
2
void main(){
}


works with most compilers / libraries, too.


Regardless of whether it works or not, it's still wrong
Topic archived. No new replies allowed.