int main(无效) { int a; double b; a = TEN_VAL; b = 7.5; 开关(a){ 案例SOME_VAL: 案例SOME_OTHER_VAL: put(AllowedVal); 休息; 案例TEN_VAL: if(b * MAGIC> = a + MAGIC){ puts(TenMagic); }否则{ puts (TenMundane); } 休息; 默认值: puts(" Default" ); 休息; } 返回0; } 编译和链接。 干杯 Michael - 电子邮件:我是一个/ at / gmx / dot / de address。This nicely illustrates why it makes sense to providea compiling minimal example. If the above is copied fromyour code, then remove CASENAME.Apart from that consider#include <stdio.h>enum A_VAL { SOME_VAL, SOME_OTHER_VAL, TEN_VAL = 10 };#define MAGIC 42int main (void){int a;double b;a = TEN_VAL;b = 7.5;switch (a) {case SOME_VAL:case SOME_OTHER_VAL:puts("AllowedVal");break;case TEN_VAL:if (b * MAGIC >= a + MAGIC) {puts("TenMagic");} else {puts("TenMundane");}break;default:puts("Default");break;}return 0;}Compiles and links.CheersMichael--E-Mail: Mine is an /at/ gmx /dot/ de address. 这篇关于在switch结构中嵌套if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-15 07:03