Created
September 15, 2021 22:26
-
-
Save twopoint718/00b3810f39ea2f15f6ab129197abf2ce to your computer and use it in GitHub Desktop.
Cases in a switch statement can have ranges (there must be space around the `...` though). It is supported by GCC and Clang.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int | |
main(int argc, char **argv) { | |
int i = 0; | |
switch(i) { | |
case 0 ... 10: | |
printf("0 through 10\n"); | |
break; | |
default: | |
printf("not 0 through 10\n"); | |
break; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment