[英]Can we call a 'Case' of Switch(); statement from anywhere else in the code [C Programming Language]
我想从 C 语言代码中的其他地方调用“switch”的“case”-语句。
这是源代码:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
char a;
int main()
{
printf("Enter a number: ");
scanf("%c", &a);
switch(a){
case 'a':
printf("This is for A & C");
break;
case 'b':
printf("This is for only B");
break;
case 'c':
// Here i want to call "case 'a':"
goto case 'a';
// how can a call another case here?
break;
default:
printf("Default");
break;
}
getch();
return 0;
}
谢谢是提前:D
您需要所谓的“跌倒”案例:
所以而不是这个:
case 'a':
printf("This is for A & C");
break;
case 'b':
printf("This is for only B");
break;
case 'c':
// Here i want to call "case 'a':"
写这个:
case 'a':
case 'c':
printf("This is for A or C");
break;
case 'b':
printf("This is for only B");
break;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.