home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!usc!howland.reston.ans.net!wupost!crcnis1.unl.edu!moe.ksu.ksu.edu!engr.uark.edu!wdraper.uark.edu!wrd
- From: wrd@wdraper.uark.edu (William R. Draper)
- Subject: Re: struct vs. typedef
- Message-ID: <1993Jan11.162844.6013@wdraper.uark.edu>
- Sender: netnews@engr.uark.edu (NetNews Administrator)
- Nntp-Posting-Host: wdraper.uark.edu
- Organization: University of Arkansas
- References: <uRL4wB7w165w@cybrspc.uucp> <JAR.93Jan10152829@solva.ifi.uio.no>
- Date: Mon, 11 Jan 1993 16:28:44 GMT
- Lines: 37
-
- jar@solva.ifi.uio.no (Jo Are Rosland) writes:
-
- >In article <uRL4wB7w165w@cybrspc.uucp> Roy M. Silvernail writes:
- >
- > typedef struct n {
- > int x,y;
- > struct n *last,*next, *up, *down;
- > void (*show)(struct n *);
- > int width;
- > void **value;
- > } ITEM;
- >
- > Now, this works, but it sure seems clumsy. Is this really the only way
- > to do this type of construct? If not, is it the optimal solution, or is
- > there some extremely clever trick I'm missing?
- >
- >Given C, that's the best you can get. You'll just have to get used to
- >it, just like the rest of us :-).
- >
-
- If you would rather, you can try:
-
- typedef struct n *ITEMPTR;
- typedef struct n {
- int x, y;
- ITEMPTR last, next, up, down;
- void (*show)(ITEMPTR);
- int width;
- void **value;
- } ITEM;
-
- I usually define it as Silvernail has, but where you have several
- instances of a pointer, it may be easier to define the pointer first.
-
- Bill
-
- email: wrd@engr.uark.edu
-