Sunday, 15 January 2012

free function

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 available 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.

No comments:

Post a Comment

host gator coupon