C examples for Memory:free
free() function takes a pointer as an argument and frees the memory the pointer refers to.
#include <stdio.h> #include <string.h> #include <stdlib.h> int main()/*ww w .j a v a 2s . co m*/ { char *name; name = (char *)malloc(80 * sizeof(char)); if (name != NULL) { printf("\nEnter your name: "); gets_s(name,80); printf("\nHi %s\n", name); free(name); //free memory resources } }