exit function cpmmand

The return command exits a function. Does this only work for Void?

int Functionname(){

   if(this == true){
      return 0;
  
    }

      //code i dont want to execute if this is true
}

If i'm not returning a value the correct command would be Void and return would work.

How do i exit an int function? or bool and char functions?

Return 0, like above doesn't work

For a void function, simply "return;"

For a non-void function, you should return an item of the same type as the function.

Could you post the actual code you say doesn't work?

Thanks,

The function I'm asking about should have been void so i changed it and fixed the issue. The bad code i had with return not working for and int function i haxed up and temporally fixed. I just put a few else if statements together to bypass the issue. Just trying to learn the correct way.

A function declared to return a value should always return a value.

In your case the code would be something like:

int Functionname(){

   if(this == true){
      return 0;
  
    }

      //code i dont want to execute if this is true
      return 1;
}

The code calling the function can then test the returned value to see if this==true or not.

If you just want to exit the function if this==true and aren't going to test the value elsewhere declare the function as void instead of int and just return;