How do i use malloc?
My program program crashes if i use it more than once.
Printable View
How do i use malloc?
My program program crashes if i use it more than once.
I can't find anything that tells me how to use it
PHP Code:
char *str;
str = (char *)malloc(10); // str now points to a block of 10 bytes (error check this)
free(str); // Free the memory
str = NULL; // So we don't accidently cause a crash by accessing memory that we free'd
ops i mean to say realloc