Mega Code Archive

 
Categories / C / Code Snippets
 

Deallocate dynamically allocated memory how to use free

#include <stdio.h> #include <stdlib.h> int main () { int *buf1, *buf2, *buf3; buf1 = (int*) malloc (10*sizeof(int)); buf2 = (int*) calloc (10,sizeof(int)); buf3 = (int*) realloc (buf2,20*sizeof(int)); free (buf1); free (buf3); return 0; }