70,020
社区成员




void Test(void){
char *str = (char *) malloc(100);
strcpy(str, "hello");
free(str);
if(str != NULL){
strcpy(str,"world");
printf("%s\n",str);
}
}
结果是world,我的疑问是free掉str以后,虽然str依然保存malloc分配的地址,但已经不能通过它使用了,为什么下面还可以调用strcpy向这个地址赋值呢?
free(str);
str = NULL;