>Hello to all,
>
>      I wnat know why the answer of the following prog. is comming  4 ?
>
>#include<stdio.h>
>#include<conio.h>
>void main()
>  {
>   unsigned char c;
>   typedef struct name
>    {
>     long a;
>     int b;
>     long c;
>    }r;
>   r re={3,4,5};
>   r *na=&re;
>   clrscr();
>   printf("%d",*(int *)((char *)na + (unsigned int)&(( (struct 
name *)0-> b )));
>   getch();
>}

here your code is a contrived int *ptr = &re.b;
so its giving the value 4. also void main needs to be int main, and a return 
0 at the end.
bcoz, main retuns the exit code or something.. read the FAQ.... your printf 
should have a \n on the end as well.

>I also want explination about this statement
>
>printf("%d",*(int *)((char *)na + (unsigned int)&(( (struct 
name *)0->b )))

&(( (struct name *)0-> b )),  if the structure was at address 0, then in 
effect you get the number bytes from the start of the structure to the b 
member.....

_________________________________________________________________
Protect your PC from viruses. Enrich your online experience. 
http://www.msn.co.in/security/ Get more from the internet.






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe : [EMAIL PROTECTED]

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=3612
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/Programmers-Town/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to