Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!purdue!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: How to include char arrays of pointers in structures Message-ID: <24109@mimsy.umd.edu> Date: 2 May 90 07:30:32 GMT References: <374@comcon.UUCP> <23890@mimsy.umd.edu> <23760@unix.cis.pitt.edu> <24003@mimsy.umd.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 In article <24003@mimsy.umd.edu> I wrote: >(You should get a diagnostic for this ... because the type of &a is >(char *(*)[10]), while the type of ptr is (char *(*)[]), and the numbers >in the brackets do not match.) Norman Diamond has pointed out that the ANSI C standard says otherwise: a pointer to an incomplete array type (one without a size) is compatible with a pointer to a complete array type of any size, provided that the types match when the size is not considered. In other words, a pointer of type T (*)[] is compatible with both one of type T (*)[10] and T (*)[20] , and a pointer of type T (*)[3] is compatible with one of type T (*)[] . This does not, however, affect my original point: there is nothing you can do with a pointer of type (T (*)[]) that you cannot do with one of type (T *), except confuse a human reading your code. (There *is* something new you can do if you put a number inside the brackets. This rule should be applied only to pointers to `sizeless' arrays.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris