#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int *ptr,a[6]={1,2,3,4,5,6};
int i;
ptr=(int*)calloc(a[6]*sizeof(int),2);
for(i=0;i<7;i++)
{
printf("\n %d",*ptr+a[i]);
}
free(ptr);
getch();
}
the program works perfectly!! but my questions
Does the declaration of a[6] inside calloc() correct. since the syntax for calloc is
ptr_var=(cast_type *)calloc(no_of_blocks,size_of_each_block);
.what does thecalloc()
and a[6] do now.What does *ptr takes value because ptr doesnt get assigned any address.
In printf does *ptr needs there.then what does it do.