Thank you very much. It works
Can you be so kind as to explain the syntax?
I can't find it in my book.
Further to bitbessier's excellent explaination, there are the requirements of the OS itself.
Windows expects certain things from programs and proscesses. One of these is that each process returns a value to the operating system upon completion. This value is normally an error report where 0 indicates success but it can be used for other purposes such as controlling batch files (IF ERRORLEVEL...) and returning process results to parent programs (eg.
GetExitCodeThread() )
This means that main() which is the first function in any console program has to return an integer value to the OS in order to be fully standards compliant.
Moreover, as already explained every C function has a return value. This can be void, any of the standard types (int, double, long, etc) or any user defined type (structs, etc.) Since every C function has a return value, with the exception of void, you are expected to actually return a value, thus the last statement in almost every function you write will be return.
Finally every C function accepts input values (called "Function Parameters") when a function is entered. Like the return values these can be any valid type. There are two exceptions to this, First is a function like ... main() ... which can accept any number of non-specified parameters and Second we have ...main(void)... which takes no parameters.
So taking all this together your minimum program skeleton is...
int main (void)
{
// your code goes here
return 0;
}
You should get into the habit of following this standard.
It's never too early to form good programming habits.