You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/ex10.c

37 lines
674 B

13 years ago
#include <stdio.h>
int main(int argc, char *argv[])
{
int i = 0;
char *states[] = {
"California", "Oregon",
"Washington", "Texas"
13 years ago
};
int num_states = 4;
13 years ago
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++) {
printf("state %d: %s\n", i, states[i]);
13 years ago
}
return 0;
}