1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include<stdio.h> #include<malloc.h> int main(void) { char **name; name = malloc(sizeof(char *) * 2); if (name == NULL) { printf("Malloc fail"); exit(1); } for (int i = 0; i < 2; i++) { name[i] = malloc(sizeof(char) * 10); } strcpy(name[0], "È«±æµ¿"); strcpy(name[1], "°°¨Âù"); for (int i = 0; i < 2; i++) { printf("%s\n", name[i]); } for (int i = 0; i < 2; i++) { free(name[i]); } free(name); return 0; } | cs |