有什么区别:
情况1:
char* strings[100];
strings[0]=malloc(100);
char str[100]="AAA";
strings[0]=strdup(str);
free(strings[0]);
案例2:
char* strings[100];
strings[0]=malloc(100);
strings[0]="AAA";
free(strings[0]);
Case2 导致崩溃。
和后面strdup
一样好。为什么第二种情况会崩溃?malloc
strcpy