int main()
{
/*
Code Here
*/
return 0;
}
If apply return -1 instead of 0 what will happen ? I use -1 also with return but my program also run successfully. Than what is the need of return statement with number.
int main()
{
/*
Code Here
*/
return 0;
}
If apply return -1 instead of 0 what will happen ? I use -1 also with return but my program also run successfully. Than what is the need of return statement with number.
Conventionally, the return value is used to determine whether a program has succeeded or failed. You can call your program from another program and record the status. The operating system records the return value of a program and infers 0 as success and non-zero as failure.
An example: if you have scheduled your program in Task Scheduler. It will interpret 0 as success and any other value as failure and display the status column of your task accordingly.