int main()
{
char s[] = "abcedfeg";
strcpy(s, "123");
printf("%s/n", s);
char *pA = (char *)malloc(sizeof(int));
char *pB = s;
free(pB);
return 0;
}
//=========================
用GDB调试;
发现:
1. s 经过 strcyp 函数拷贝之后,内存有原来的: s = "abcedfeg" -> s = "123/000dfeg"
2. free一个不是从堆中申请的内存,会提示如下错误:
warning: HEAP[a.exe]
warning: Invalid Address specified to RtlFreeHeap(03E0000, 0022FF5B)