Thanx a ton tabstop, nonoob, anduril462
I have developed a short code (using calloc). Can u please check it carefully if I have made any mistakes ,like memory leaks etc.. (although I have checked it by printing the outputs, but am not shure about memory leaks)
Code:
typedef struct species
{
int * niche;
} species;
void main()
{
const int TotalSpecies = 3;
species s[TotalSpecies];
int i,j,nichesize;
for( i = 0; i < TotalSpecies; i++)
{
printf("enter the niche size of specie %d \n",i);
scanf("%d",&nichesize);
s[i].niche = calloc(nichesize,sizeof(int));
printf("enter the niche value(s) of specie %d\n",i);
for(j=0;j<nichesize;j++)
scanf("%d",&s[i].niche[j]);
}
for( i = 0; i < TotalSpecies;i++)
free(s[i].niche);
}
Thanx a lot u all
Regards
Alice