Tutorials Point


  Learning C
  C Function References
  C Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     About TP     Advertising  

C - free function

previous

Synopsis:

#include <stdio.h>

void free(void *mem_address); 

Description:

A block of memory previously allocated using a call to malloc, calloc or realloc is deallocated, making it availbale again for further allocations.

Return Value

None.

Example

#include <stdio.h>

int main ()
{
  int * buffer1, * buffer2, * buffer3;
  buffer1 = (int*) malloc (100*sizeof(int));
  buffer2 = (int*) calloc (100,sizeof(int));
  buffer3 = (int*) realloc (buffer2,500*sizeof(int));
  free (buffer1);
  free (buffer3);
  return 0;
}

It will proiduce following result:

This program has no output.
This is just demonstration of allocation and deallocation of memory.


previous Printer Friendly

Advertisements


  

Advertisements