From b1172d6c6e3b86f001227f9ced91b5fff9194b44 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 18 Jun 2011 15:06:29 -0400 Subject: [PATCH] futzing with relationship between switch/case and labels --- .gitignore | 2 ++ Makefile | 3 ++- gowrikumar/src/05-switchint.c | 24 ++++++++++++++++++++++++ gowrikumar/src/05b-switchint.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 gowrikumar/src/05-switchint.c create mode 100644 gowrikumar/src/05b-switchint.c diff --git a/.gitignore b/.gitignore index d800b0d..fe46976 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ gowrikumar/bin +*.i +*.s diff --git a/Makefile b/Makefile index ac357a5..e1682e8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ CD = cd RM = rm -v -CFLAGS := -std=c99 +CC := gcc +CFLAGS := -std=c99 -Wall export CD RM CFLAGS diff --git a/gowrikumar/src/05-switchint.c b/gowrikumar/src/05-switchint.c new file mode 100644 index 0000000..6a5b568 --- /dev/null +++ b/gowrikumar/src/05-switchint.c @@ -0,0 +1,24 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +int main() +{ + int a=10; + switch(a) + { + case '1': + printf("ONE\n"); + break; + case '2': + printf("TWO\n"); + break; + defa1ut: + printf("NONE\n"); + } + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/gowrikumar/src/05b-switchint.c b/gowrikumar/src/05b-switchint.c new file mode 100644 index 0000000..99368be --- /dev/null +++ b/gowrikumar/src/05b-switchint.c @@ -0,0 +1,32 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#define MAGIC_NUMBER 10 + +#include +int main() +{ + int a = MAGIC_NUMBER; + switch(a) + { + case '1': + printf("ONE\n"); + break; + case '2': + printf("TWO\n"); + break; + defalut: + printf("NO CAN SPELL\n"); + break; + defau1t: + printf("SO CLOSE, YET SO FAR\n"); + break; + default: + printf("NONE\n"); + } + return 0; +} + +/* vim:filetype=c:fileencoding=utf-8 + */