Last active
January 31, 2023 08:45
-
-
Save uucidl/cf8472fed08f02536f7ed9a162e7f0f1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#define case(__x__) break; case __x__ | |
#define fallthrough(__x__) case __x__ | |
#define otherwise break; default | |
#include <assert.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
switch(argc) { | |
case(0): printf("surprising\n"); | |
case(1): printf("no argument given\n"); | |
case(2): printf("a single argument given %s\n", argv[1]); | |
case(3): fallthrough(4): fallthrough(5): printf("between 2 and 4 arguments given\n"); | |
otherwise: printf("over 4 arguments given\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment