Skip to content

Instantly share code, notes, and snippets.

@tetsuok
Last active December 15, 2015 17:49
Show Gist options
  • Select an option

  • Save tetsuok/5298854 to your computer and use it in GitHub Desktop.

Select an option

Save tetsuok/5298854 to your computer and use it in GitHub Desktop.
Toy programs to verify nested cases.
#include <stdio.h>
void test_case(int n) {
switch (n) {
case 0:
case 1:
printf("case %d\n", n);
break;
case 2:
printf("case %d\n", n);
break;
case 3:
printf("case %d\n", n);
break;
default:
printf("default n = %d\n", n);
}
}
int main(void) {
int i;
for (i = 0; i < 5; i++) {
test_case(i);
}
return 0;
}
#include <stdio.h>
void test_case(int n) {
switch (n) {
case 0:
case 1:
printf("case %d\n", n);
break;
case 2:
printf("case %d\n", n);
break;
case 3:
{
printf("case %d\n", n);
break;
default:
printf("default n = %d\n", n);
}
}
}
int main(void) {
int i;
for (i = 0; i < 5; i++) {
test_case(i);
}
return 0;
}
CC = gcc
CFLAGS = -O0
FILES = \
case.s \
case2.s
all: $(FILES)
diff case.s case2.s
clean:
-rm -f *.s
.c.s:
$(CC) $(CFLAGS) -S $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment