我可以使用Goto跳转到其他函数吗?例如
void x(){
printf("hello");
}
void y(){
printf("hi");
}
int main(){ /*assume that all var are declared */
scanf("%d",&input);
if(input == 1) goto y();
else(input == 2) goto x();
}
最佳答案
您不能使用goto
分支到不同的函数; goto
只能在当前函数内分支。您只需调用函数x()
和y()
。
关于c - 如何使用Goto功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18409073/