作业帮 > 综合 > 作业

求此程序结果!#include int first;int second;void callee ( int first

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/18 03:57:16
求此程序结果!
#include
int first;
int second;
void callee ( int first )
{
int second;
second = 1;
first = 2;
printf("callee:first = %d second = %d\n",first,second);
}
int main (int argc,char *argv[])
{
first = 1;
second = 2;
callee(first);
printf("caller:first = %d second = %d\n",first,second);
return 0;
}
callee:first=2 second=1
caller:first=1 second=2
在调用callee的时候,将main函数里的first传进去,只不过把first的值传了进去,callee里的first是一个新的变量,值为刚才传进来的值,在进行赋值后,callee里的first和second是变了,但是不影响全局的那个first和second,所以输出的结果就会是这样.