hey guys, a certain thread confused me saying that
malloc allocates memory contiguously but
calloc DOES NOT allocate memory contiguously
Is that correct ?
I tried writing this program and deduced that CALLOC IS ALSO CONTIGUOUS
Code:
#include<stdio.h>
#include<conio.h>
int main(void)
{
char* ptrm;
char* ptrc;
int i=0;
ptrc=(char*)calloc(5,sizeof(char));
printf("\nCalloced" );
for(i=0;i<5;i++)
{
printf("\n%x",ptrc+i);
}
printf("\n\n");
printf("\nMalloced ");
ptrm=(char*)malloc(5*sizeof(char));
for(i=0;i<5;i++)
{
printf("\n%x",ptrm+i);
}
getch();
return 0;
}
Please correct me.