代码应该改进,但我认为这是你想要的。
const char *containers_1[] = {"one","two","why do I stuck in this problem"};
const char *containers_2[] = {"Other","string","here","whis","has","more"};
main(int argc, char **argv) {
char ** tmp1;
int i, size;
size = sizeof(containers_1);
printf ("%d\n", size);
tmp1 = malloc(size);
memcpy(tmp1, containers_1, sizeof(containers_1));
for (i=0; i< size/sizeof(char *); i++) {
printf("%s\n", tmp1[i]);
}
size = sizeof(containers_2);
printf ("%d\n", size);
tmp1 = malloc(size);
memcpy(tmp1, containers_2, sizeof(containers_2));
for (i=0; i< size/sizeof(char *); i++) {
printf("%s\n", tmp1[i]);
}
}