Reputation: 3
while(str[i]!='\0')
{
if(str[i]!=str1[i])
{
printf("not equal");
return 1;
}
i++;
}
printf ("equal");
return 0;
What happens here if we use return 1. Will return 1 terminate the if condition or the whole loop?
Upvotes: 0
Views: 1343
Reputation: 36082
it exists the current scope
e.g.
int foo()
{
return 42;
}
int main()
{
int n = 0;
do
{
n = foo();
printf("received %d\n",n); /* will print "received 42" */
}
while (n != 42) // will quit since n == 42
return 0; // returns 0 to the operating system
}
Upvotes: 1