EmbLogic's Blog

calloc

int *data;
data=calloc(3,sizeof(int));
int i=0;
for(i=0;i<3;i++)
scanf("%d",&data[i]);
for(i=0;i<3;i++)
printf("%d",data[i]);
free(data)

//i get segmentataion fault….

One Response to calloc

  1. it will work fine…but u should try it using *(data+i) in the printf statement apart form the data[i] notation…

Leave a Reply to saurabh.aggarwal Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>