13
Bagaimana cara kerja malloc () dan gratis ()?
Saya ingin tahu bagaimana mallocdan freebekerja. 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; } Saya akan sangat berterima kasih jika …
276
c++
c
memory-management
malloc
free