Date: Fri, 17 May 2002 11:04:06 +0100 (BST) From: Jan Grant <Jan.Grant@bristol.ac.uk> To: shubhamr <shubhamr@malkauns.nsc.com> Cc: "questions@FreeBSD.ORG" <questions@freebsd.org> Subject: Re: confusion in C Message-ID: <Pine.GSO.4.44.0205171056100.28228-100000@mail.ilrt.bris.ac.uk> In-Reply-To: <3CE4D043.DCB731F4@malkauns.nsc.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 17 May 2002, shubhamr wrote: > am confused a bit over > &a->b->c. > > can someone clear as to what it means? > > shubha Yes, it means &(a->b->c), that is, the address of the c. I dunno if this will help, but... #include <stdlib.h> #include <stdio.h> struct B { int c; }; struct A { struct B *b; }; main() { struct A *a = malloc(sizeof(struct A)); struct B *b = a->b = malloc(sizeof(struct B)); int *ptr_to_int = &a->b->c; b->c = 1234; if (*ptr_to_int == 1234) printf("&a->b->c has followed the links\n"); } -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287088 Fax +44 (0)117 9287112 RFC822 jan.grant@bris.ac.uk printf 'cat\nhello world' | `sh -c 'read c; echo $c'` To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.44.0205171056100.28228-100000>