using NULL sentinel instead of num_states
This commit is contained in:
parent
16785fe9f2
commit
5b7748c99a
9
ex10.c
9
ex10.c
@ -10,12 +10,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
char *states[] = {
|
char *states[] = {
|
||||||
"California", "Oregon",
|
"California", "Oregon",
|
||||||
"Washington", "Texas"
|
"Washington", "Texas",
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
int num_states = 4;
|
char *state = "";
|
||||||
|
|
||||||
for(i = 0; i < num_states; i++) {
|
for(i = 0; NULL != (state = states[i]); i++) {
|
||||||
printf("state %d: %s\n", i, states[i]);
|
printf("state %d: %s\n", i, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user