ex11
This commit is contained in:
parent
120a767002
commit
609dbcb7d8
1
lcthw-remnants-2/.gitignore
vendored
1
lcthw-remnants-2/.gitignore
vendored
@ -8,3 +8,4 @@ ex8
|
||||
ex9
|
||||
ex9-ec
|
||||
ex10
|
||||
ex11
|
||||
|
27
lcthw-remnants-2/ex11.c
Normal file
27
lcthw-remnants-2/ex11.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user