Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int mode = 0;
- int doipass = 1; // changed between tests
- for (mode = 0; mode < 3; mode++) {
- printf("We're in mode %i and the if will %sfail\n", mode, doipass?"not ":"");
- switch (mode) {
- case 0: if (doipass) {
- case 1: printf("case1\n");
- break;
- } else {
- case 2: printf("case2\n");
- break;
- }
- }
- }
- }
- ultimation@NoizeBox:~/temp$ ./test
- We're in mode 0 and the if will fail
- case2
- We're in mode 1 and the if will fail
- case1
- We're in mode 2 and the if will fail
- case2
- ultimation@NoizeBox:~/temp$ ./test
- We're in mode 0 and the if will not fail
- case1
- We're in mode 1 and the if will not fail
- case1
- We're in mode 2 and the if will not fail
- case2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement