Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Question on structures Message-ID: <8888@utzoo.UUCP> Date: Wed, 4-Nov-87 17:56:59 EST Article-I.D.: utzoo.8888 Posted: Wed Nov 4 17:56:59 1987 Date-Received: Wed, 4-Nov-87 17:56:59 EST References: <1025@phoenix.Princeton.EDU> Organization: U of Toronto Zoology Lines: 22 Keywords: Sturctures records > I have gotten really tired of typing things like a.b.c.d etc to refer to > elements of a structure. I remember that pascal provided me with a 'with' > construction which allowed me to say something like > "with a.b.c {now refering to d really means use a.b.c.d } ..." > I was wondering if there is some similar contruct in C... Nothing quite the same, but you can come close. If all you want is the abbreviation, just #define IT a.b.c and then refer to IT.d or whatever. If you also want the efficiency boost that some Pascal compilers give you this way, then struct whatever *it = &a.b.c; and then refer to it->d or whatever. These aren't quite as convenient as Pascal when there is only one structure in use, but unlike Pascal they work even when there is more than one (just use separate IT/it names). -- Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology are condemned to reinvent it. | {allegra,ihnp4,decvax,utai}!utzoo!henry