back to initial state

This commit is contained in:
Dan Buch 2011-09-09 14:37:10 -04:00
parent 947ce04319
commit 45ca45c9e1

24
ex10.c
View File

@ -3,31 +3,17 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i = 0; int i = 0;
for(i = 0; i < argc; i++) {
printf("arg %d: %s\n", i, argv[i]);
}
char *states[] = { char *states[] = {
"California", "Oregon", "California", "Oregon",
"Washington", "Texas" "Washington", "Texas"
}; };
int num_states = 4; int num_states = 4;
char *tmp = states[0];
states[0] = argv[0];
argv[0] = tmp;
for(i = 0; i < argc; i++) {
printf("arg %d: %s\n", i, argv[i]);
}
for(i = 0; i < num_states; i++) {
printf("state %d: %s\n", i, states[i]);
}
argv[0] = states[0];
states[0] = tmp;
for(i = 0; i < argc; i++) {
printf("arg %d: %s\n", i, argv[i]);
}
for(i = 0; i < num_states; i++) { for(i = 0; i < num_states; i++) {
printf("state %d: %s\n", i, states[i]); printf("state %d: %s\n", i, states[i]);
} }