2011-09-10 04:22:25 +00:00
|
|
|
#include <stdio.h>
|
2011-09-10 05:06:06 +00:00
|
|
|
#include <string.h>
|
2011-09-10 04:22:25 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-09-10 04:27:04 +00:00
|
|
|
int i = 0;
|
|
|
|
while(i < argc) {
|
|
|
|
printf("arg %d: %s\n", i, argv[i]);
|
|
|
|
i++;
|
2011-09-10 04:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *states[] = {
|
|
|
|
"California", "Oregon",
|
|
|
|
"Washington", "Texas"
|
|
|
|
};
|
|
|
|
|
|
|
|
int num_states = 4;
|
|
|
|
i = 0;
|
|
|
|
while(i < num_states) {
|
|
|
|
printf("state %d: %s\n", i, states[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-09-10 04:29:54 +00:00
|
|
|
i = 0;
|
2011-09-10 05:06:06 +00:00
|
|
|
size_t l;
|
|
|
|
|
2011-09-10 04:29:54 +00:00
|
|
|
while(i < num_states) {
|
2011-09-10 05:06:06 +00:00
|
|
|
l = strlen((char *)&(argv[i]));
|
|
|
|
strncpy((char *)&(states[i]), (char *)&(argv[i]), l);
|
2011-09-10 04:33:57 +00:00
|
|
|
printf("copied %s into state %d\n", states[i], i);
|
2011-09-10 04:29:54 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-09-10 05:06:06 +00:00
|
|
|
i = 0;
|
|
|
|
while(i < num_states) {
|
|
|
|
printf("state %d: %s\n", i, states[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-09-10 04:22:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|