Preguntas con la etiqueta [free]

Lista free preguntas

¿Cómo funcionan malloc() y free()?

13
respuestas
322
votos
203.7k
vistas

Quiero saber como mallocy freetrabajar. 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