Free Function in C


The C library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc.

Source Code

//free function
#include<stdio.h>
#include<stdlib.h>
 
int * getting_values()
{
    int i;
    int *ptr=(int *)malloc(3*sizeof(int));
    for(i=0; i<3; i++)
    {
        printf("Enter a integer : ");  //10,20,30
        scanf("%d",ptr+i);
    }
    return ptr;
}
 
int main()
{
    int i,n=0;
    int *ptr=getting_values();
     for(i=0; i<3; i++)
    {
        n+=*(ptr+i);  //n=n+10  => +20 =>+30
    }
     printf("Total : %d  ",n);
     free(ptr);
     ptr=NULL;
    return 0;
}
 
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes