The return statement tells the running function that it should stop running and give back execution to the called. While doing that a value is returned (for non-void type functions) indicating the result of the function.
Example: provide the calculated value of a function
static int Add(int a, int b)
{
return a + b;
}
Example: leave a function early
static void PrintIfNonEmpty(const char * name)
{
if (name == NULL || name[0] == '\0') // if the pointer is not set or the name is an empty string
return;
printf("Your name is %s.", name);
}
For details, please read https://docs.microsoft.com/en-us/cpp/c-language/return-statement-c.