Default value of return

Aug 6, 2015 at 3:18pm
If i have this code

1
2
3
if(somethingNotRight){
return;
}


What is it that Im returning? Is it just to terminate the program or the function? im confuse

Does it mean return 0?
Last edited on Aug 6, 2015 at 3:19pm
Aug 6, 2015 at 3:55pm
You don't show the type of the enclosing function.

If the the enclosing function is type int (like main), that statement generates a compiler warning because the type of the return (void) does not match the type of the function.

If the enclosing function is of type void, then the return is okay and returns nothing.
Topic archived. No new replies allowed.