Switch to NULL-terminated 2D array
This commit is contained in:
parent
5381d5f0ce
commit
d4b5c737e5
11
lcthw/ex13.c
11
lcthw/ex13.c
@ -11,13 +11,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// let's make our own array of strings
|
// let's make our own array of strings
|
||||||
char *states[] = {
|
char *states[] = {
|
||||||
"California", "Oregon",
|
"California",
|
||||||
"Washington", "Texas",
|
"Oregon",
|
||||||
|
"Washington",
|
||||||
|
"Texas",
|
||||||
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
int num_states = 4;
|
for (i = 0; states[i] != NULL; i++) {
|
||||||
|
|
||||||
for (i = 0; i < num_states; i++) {
|
|
||||||
printf("state %d: %s\n", i, states[i]);
|
printf("state %d: %s\n", i, states[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user