u hv answered ur ques in ur ques itself...:)
c u understand size of struct node as 4+4=8 rite?? now in this 4 is size of
int and 4 is the size of the pointer of the type struct node...
now wat are p and q? dey are also pointers to struct node jst like
link...now whn u understand dat the size of link is 4 thn u shudnt have any
trouble understanding p and q as well...
I hope im clear..:)

On Tue, Jul 26, 2011 at 1:43 AM, Nitish Garg <nitishgarg1...@gmail.com>wrote:

> This following code produces output as 8 4 4.
>
> 8 is fine, as the size of an int plus a pointer is 8, but why the size of p 
> and q is being shown as 4?
>
> #include<stdio.h>#include<stdlib.h>int main(){
>     struct node
>     {
>            int data;
>            struct node * link;
>     };
>     struct node *p, *q;
>     printf("%d ", sizeof(struct node));
>     p = (struct node *)calloc(sizeof(struct node) , 1);
>     q = (struct node *)calloc(sizeof(struct node) , 1);
>     printf("%d %d", sizeof(p), sizeof(q));
>     getchar();}
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/8bw2jFtQHBsJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Aditi Garg
Undergraduate Student
Electronics & Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

9718388816

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to