Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ncar!ames!elroy!gryphon!sarima From: sarima@gryphon.COM (Stan Friesen) Newsgroups: comp.lang.c Subject: Re: C pointers Keywords: C Message-ID: <12042@gryphon.COM> Date: 13 Feb 89 22:01:17 GMT References: <1707@shaffer.UUCP> Reply-To: sarima@gryphon.COM (Stan Friesen) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 30 In article <1707@shaffer.UUCP> jcrowe@shaffer.UUCP (Joe Crowe) writes: > >typedef struct XYZ >{ > . > . > . > struct diag_cmd (*p_cmd_blk)[]; > . > . >} t_xyz; > > I am allocating storage for the above structures dynamically and >setting the pointer p_cmd_blk manually. All of this works. But when >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?? > Even though I have seen one article with the correct solution, (you probably meant 'struct diag_cmd *p_cmd_blk'), I will put in my two cents worth. This confusion between pointers to the first element of an array and pointers to arrays is very common. I would recommend that Mr Koenig's "C Traps and Pitfalls" become standard reading for everyone learning 'C'. It has an excellent chapter on just this issue, and is probably worth the price just for that chapter alone. -- Sarima Cardolandion sarima@gryphon.CTS.COM aka Stanley Friesen rutgers!marque!gryphon!sarima Sherman Oaks, CA