diff --git a/ex10.c b/ex10.c index 7cf8284..b1ea6a6 100644 --- a/ex10.c +++ b/ex10.c @@ -3,9 +3,9 @@ int main(int argc, char *argv[]) { int i = 0; - char *arg; + char *arg = ""; - for(i = 0; i < argc && (arg = argv[i]); i++) { + for(i = 0, arg = ""; i < argc && (arg = argv[i++]);) { printf("arg %d: %s\n", i, arg); } @@ -15,8 +15,8 @@ int main(int argc, char *argv[]) }; int num_states = 4; - for(i = 0; i < num_states; i++) { - printf("state %d: %s\n", i, states[i]); + for(i = 0, arg = ""; i < num_states && (arg = states[i++]);) { + printf("state %d: %s\n", i, arg); } return 0;