Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!zardoz.cpd.com!tmiuv0!rick From: rick@tmi.com Newsgroups: comp.sys.amiga.programmer Subject: Re: Is this valid C? Message-ID: <4865@tmi.com> Date: 20 May 91 11:43:10 GMT References: <1991May5.222328.16225@csis.dit.csiro.au> <616@lysator.liu.se> <38542@ditka.Chicago.COM> Organization: Technology Marketing Inc., Irvine, CA Lines: 36 In article , dillon@overload.Berkeley.CA.US (Matthew Dillon) writes: > That is, assuming 'p' is initialized to something valid :-) > > struct foop *p; > struct foop { int a; char *b }; > struct foop xx; > > main() > { > p = &xx; > p->a = 39; ... > } > And generally, it's nicer to declare the struct before declaring a pointer to it. The compiler doesn't care which goes first usually, but it's nicer for the programmer to see: struct foop { int a; char *b }; struct foop *p; struct foop xx; Also, although your compiler may not care, you need a semicolon after the declaration of the second member of struct foop: struct foop { int a; char *b; }; ^ -- .--------------------------------------------------------------------------. |[- O] Rick Stevens | | ? EMail: uunet!zardoz!tmiuv0!rick -or- uunet!zardoz!xyclone!sysop | | V (rick@tmi.com) (sysop@ssssc.com) | | CIS: 75006,1355 (75006.1355@compuserve.com from Internet) | | | | "If it's stupid and it works, it ain't stupid!" | `--------------------------------------------------------------------------'