malloc()和free()是如何工作的?我想知道malloc和free工作。int main() {
unsigned char *p = (unsigned char*)malloc(4*sizeof(unsigned char));
memset(p,0,4);
strcpy((char*)p,"abcdabcd"); // **deliberately storing 8bytes**
cout << p;
free(p); // Obvious Crash, but I need how it works and why crash.
cout << p;
return 0;}如果有可能的話,如果答案是深度的話,我會非常感激的。
malloc()和free()是如何工作的?
慕尼黑5688855
2019-06-14 10:51:45
