I have a function like
int myfun(int *a, int *b)
{
while(some condition)
{
if(condition) return *a + *b;
else
{
some manipulation;
}
}
return -1;
}
When first return statement in while->if part is encountered,does the control go to the function calling myfun or while loop still continues?Why is the return -1 statement needed?
After the return *a+*b
the function returns that and ends. You need the return -1
because if that condition is never met, what will it return? It is a int
function so it has to return something.