【发布时间】:2017-11-27 20:57:07
【问题描述】:
我已经编写了这段代码,并尝试使用默认的 GCC 编译器在代码块中编译它。
当给出选项 1 时,我得到这个输出“hello world6356744”。
请解释发生了什么。
#include<stdio.h>
#include<stdlib.h>
int fun1(int x,int y)
{
printf("hello world");
return x+y;
}
int fun2()
{
return 0;
}
int main()
{
printf("type 1 for * or type 2 for #");
int a;
scanf("%d", &a);
int ca1;
switch(a)
{
case 1:
ca1=fun1(2,3);
printf("%d", &ca1);
break;
case 2:
fun2();
break;
default:
printf("invalid input");
}
return 0;
}
【问题讨论】:
-
你希望它做什么?该输出是我所期望的
标签: c function switch-statement