while(str[i]!='\0')
{
if(str[i]!=str1[i])
{
printf("not equal");
return 1;
}
i++;
}
printf ("equal");
return 0;
如果使用return 1,会发生什么情况。 返回1会终止if条件还是整个循环?
答案 0 :(得分:1)
它存在当前范围
例如
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
}