debasish deka wrote:
> Wish you a Good Day,
> In the following code :
> struct mystruct {
>     char a;
>     int b;
>     short c;
>     char d;
> };
> 
> int main(int argc, char *argv[])
> {
>     
>     char ch;
>     int i;
>     struct mystruct foo[3];
> 
>     printf("&foo[0]=%p\t&foo[1]=%p\t&foo[2]=%p\t&ch=%p\t&i=%p\n",   \
>     &foo[0], &foo[1], &foo[2], &ch, &i);
> 
> 
>   system("PAUSE");    
>   return 0;
> }
> 
> 
> The output was :
> &foo[0]=0022FF30
> &foo[1]=0022FF3C
> &foo[2]=0022FF48
> &ch=0022FF6F
> &i=0022FF68
> 
> 
> Now my doubt is, char ch and int i being declared earlier to struct mystruct 
> foo[3] are assigned lower memory location compared to the array of 
> structures. Why does it happen like this ?
> 
> With Regards,
> Debasish

Your compiler decided to do that.  Stacks typically "grow downward" but 
there is no guarantee of that.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to