# Evaluation in return statement

``````//prog1.c
#include <stdio.h>
int f(int *a,int *b,int c) {
if(c == 0) return 1;
else {
*a = *a + 1;
*b = *b - 1;
c =  c - 1;
return (*a + f(a,b,c) + *b);
}
}
int main() {
int a = 3,b = 3,c = 3;
printf("%d\n",f(&a,&b,c));
return 0;
}
``````

``````//prog2.c
#include <stdio.h>
int f(int *x,int *y,int *z) {
*x = *x + 1;
*y = *y + 1;
*z = *z + 1;
return 0;
}
int main() {
int a=0,b=0,c=0;
printf("%d %d %d\n",a,f(&a,&b,&c),b);;
return 0;
}
// gcc output : 1 0 0
// clang-3.5 :  0 0 1
``````

`prog1.c`中， `return`语句中是否有任何特定于实现的行为？ 如果不是，它是如何评估的？

``````#include <stdio.h>

int f(int *a,int *b,int c) {
if(c == 0) return 1;
else {
*a = *a + 1;
*b = *b - 1;
c =  c - 1;
return (*a + f(a,b,c) + *b);
}
}

int main() {
int a = 3,b = 3,c = 3;
printf("%d\n",f(&a,&b,c));
return 0;
}
``````

``````#include <stdio.h>
int f(int *x,int *y,int *z) {
*x = *x + 1;
*y = *y + 1;
*z = *z + 1;
return 0;
}
int main() {
int a=0,b=0,c=0;
printf("%d %d %d\n",a,f(&a,&b,&c),b);;
return 0;
}
``````

`return`语句没有任何问题，除了如果您最初使用`c``f`的调用是否定的，则递归调用将是无止境的。

``````if(c <= 0) return 1;
``````