making a mess in my for-loops
This commit is contained in:
parent
e580f39207
commit
7fbe80ce25
8
ex10.c
8
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;
|
||||
|
Loading…
Reference in New Issue
Block a user