the follwing code is run successfully ...
typedef struct _s
{
int *r;
}s;
void main()
{
s *u;
int y=1000;
u=malloc(sizeof(s)*8);
u->r=malloc(sizeof(int)*8);
u->r[5]=y;
printf("%d\n",u->r[5]);
getch();
}
but i write the follwing code as above but gives error ....i use structure.....may why i know the reason....? if i use double pointer like (...e **h...) produces correct output... but the reason is...?
typedef struct _e
{
int r;
}e;
typedef struct _s
{
e *h;
}s;
void main()
{
s *u;
int y=1000;
u=malloc(sizeof(s)*8);
u->h=(e*)malloc(sizeof(e)*10);
u->h[1]=y;
printf("%d\n",u->h[1]);
getch();
}