C
function malloc()
is defined under stdlib.h
.
It should give an error if we don't include this file, but this code works fine with a little warning.
My question is, if malloc()
works without this header file, then why do we need to include it? Please help clarify my concepts.
# include <stdio.h>
int main()
{
int a, b, *p;
p = (int*)malloc(sizeof(int)*5);
for(a=0;a<5;a++)p[a]=a*9;
for(b=0;b<5;b++)printf("%d ",p[b]);
}