c - Default case in a switch condition -
i have code:
#include<stdio.h> int main() { int a=10; switch(a) { case '1': printf("one\n"); break; case '2': printf("two\n"); break; defalut: printf("none\n"); } return 0; }
the program doesn't print anything, not none
. figured out default
had typo defalut
!
want know why syntax error not detected compiler.
defalut
label in program can jump goto
. having editor highlights keywords have made error easier spot.
i should note program may have logic errors. character '1'
not same 1
, , same '2'
, 2
.
Comments
Post a Comment