From owner-freebsd-questions Fri May 17 3: 5:18 2002 Delivered-To: freebsd-questions@freebsd.org Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by hub.freebsd.org (Postfix) with ESMTP id CD82937B40A for ; Fri, 17 May 2002 03:05:04 -0700 (PDT) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Fri, 17 May 2002 11:04:56 +0100 Received: from cmjg (helo=localhost) by mail.ilrt.bris.ac.uk with local-esmtp (Exim 3.16 #1) id 178eal-0000VR-00; Fri, 17 May 2002 11:04:07 +0100 Date: Fri, 17 May 2002 11:04:06 +0100 (BST) From: Jan Grant X-X-Sender: cmjg@mail.ilrt.bris.ac.uk To: shubhamr Cc: "questions@FreeBSD.ORG" Subject: Re: confusion in C In-Reply-To: <3CE4D043.DCB731F4@malkauns.nsc.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include 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