This is my program:
main()
{
printf(\"hello world\\n\");
}
I get this warning when compiling it:
function should retur
There are few things which you should take note of :
int
is the main()
function's return type. That means that the kind of value main()
can
return is an integer.main( )
was tolerated by the C90 compilers but not by C99 compilers which means its not a part of C99 standard anymore , so don't do this.void main()
is not a standard form ,some compilers allow this, but none of the standards have ever listed it as an option. Therefore,
compilers don't have to accept this form, and several don't. Again, stick to the standard form,
and you won't run into problems if you move a program from one compiler to another.And one last thing , instead of writing main like this :
int main()
// here you are being silent about passing arguments to main , meaning it may or may not take arguments
write like this :
int main(void)// this specifies there are no arguments taken by main
You might wanna look at the C99 standard for further details.