The following code is given in my Data Structure reference book.
#include<stdio.h>
main()
{
int i, *pi;
float f, *pf;
pi = (int *) malloc(sizeof(int));
pf = (float *) malloc(sizeof(float));
*pi = 1024;
*pf = 3.14;
printf("an integer = %d, a float = %f", *pi, *pf);
free(pi);
free(pf);
}
But when i compile it, it gives the following error:
malloc.c: In function ‘main’:
malloc.c:6:15: warning: incompatible implicit declaration of built-in function ‘malloc’
malloc.c:11:2: warning: incompatible implicit declaration of built-in function ‘free’