42 lines
758 B
C
42 lines
758 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int i = 0;
|
|
while(i < argc) {
|
|
printf("arg %d: %s\n", i, argv[i]);
|
|
i++;
|
|
}
|
|
|
|
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++;
|
|
}
|
|
|
|
i = 0;
|
|
size_t l;
|
|
|
|
while(i < num_states) {
|
|
l = strlen((char *)&(argv[i]));
|
|
strncpy((char *)&(states[i]), (char *)&(argv[i]), l);
|
|
printf("copied %s into state %d\n", states[i], i);
|
|
i++;
|
|
}
|
|
|
|
i = 0;
|
|
while(i < num_states) {
|
|
printf("state %d: %s\n", i, states[i]);
|
|
i++;
|
|
}
|
|
|
|
return 0;
|
|
}
|