From 609dbcb7d8742b72aad935b6c0219a41ffeb1f87 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 12 Apr 2016 12:10:40 -0400 Subject: [PATCH] ex11 --- lcthw-remnants-2/.gitignore | 1 + lcthw-remnants-2/ex11.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lcthw-remnants-2/ex11.c diff --git a/lcthw-remnants-2/.gitignore b/lcthw-remnants-2/.gitignore index 40a558d..6ae8d6e 100644 --- a/lcthw-remnants-2/.gitignore +++ b/lcthw-remnants-2/.gitignore @@ -8,3 +8,4 @@ ex8 ex9 ex9-ec ex10 +ex11 diff --git a/lcthw-remnants-2/ex11.c b/lcthw-remnants-2/ex11.c new file mode 100644 index 0000000..6430125 --- /dev/null +++ b/lcthw-remnants-2/ex11.c @@ -0,0 +1,27 @@ +#include + +int main(int argc, char *argv[]) +{ + // go through each string in argv + + int i = 0; + while(i < argc) { + printf("arg %d: %s\n", i, argv[i]); + i++; + } + + // let's make our own array of strings + char *states[] = { + "California", "Oregon", + "Washington", "Texas" + }; + + int num_states = 4; + i = 0; // watch for this + while(i < num_states) { + printf("state %d: %s\n", i, states[i]); + i++; + } + + return 0; +}