Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!cjc From: cjc@ulysses.homer.nj.att.com (Chris Calabrese[mav]) Newsgroups: comp.lang.c Subject: Re: C pointers Summary: pointer to array vs array of pointers Message-ID: <11216@ulysses.homer.nj.att.com> Date: 13 Feb 89 20:37:33 GMT References: <1707@shaffer.UUCP> <3374@xyzzy.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 31 In article <3374@xyzzy.UUCP>, throopw@xyzzy.UUCP (Wayne A. Throop) writes: | > jcrowe@shaffer.UUCP (Joe Crowe) | > I have a structure which contains among | > other things a pointer to an array of structures declared as follows: | > typedef struct XYZ | > { ... | > struct diag_cmd (*p_cmd_blk)[]; | > ... } t_xyz; | > I try various methods of accessing a structure member one of the array | > of structures I am getting compiler errors. I have tried most combinations | > but with no luck. Any ideas?? | | Um.... maybe I'm being naive myself, but did you try the obvious one, | the one you declared it with? That is, | | (*t_xyz.p_cmd_blk)[N] Um...isn't (*p_cmd_blk)[] an array of pointers, not a pointer to an array? try *(p_cmd_blk[]). K&R (old) Page 110 says that int *b[10] is an array of 10 pointers to int; therefore, struct diag_cmd *p_cmd_blk[] should be an array of pointers to struct diag_cmd. Somehow I doubt that the parens around *p_cmd_blk are grouping things differently. Ayway, there's always struct diag_cmd **p_cmnd_blk. -- Name: Christopher J. Calabrese Brain loaned to: AT&T Bell Laboratories, Murray Hill, NJ att!ulysses!cjc cjc@ulysses.att.com Obligatory Quote: ``Now, where DID I put that bagel?''