Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!rlgvax!vrdxhq!bms-at!stuart From: stuart@bms-at.UUCP (Stuart D. Gathman) Newsgroups: comp.lang.c Subject: Re: Arrays of Unknown Length in Structures (and sizeof) Message-ID: <479@bms-at.UUCP> Date: Tue, 6-Oct-87 00:34:09 EDT Article-I.D.: bms-at.479 Posted: Tue Oct 6 00:34:09 1987 Date-Received: Fri, 9-Oct-87 02:29:07 EDT References: <243@mit-prep.ARPA> <1044@ius1.cs.cmu.edu> <95@aimt.UUCP> Organization: Business Management Systems, Inc., Fairfax, VA Lines: 13 Summary: a quick definition A variable size array can usefully be declared as the last element of a structure. The size returned by sizeof is the 'minimum' size of the structure. Arrays of the structure are created using the minimum size, but are rarely useful. A minimum size of [1] works with any compiler (that doesn't reorder structure elements). Some compilers allow [0] or []. A logical equivalent of the construct is to include a pointer to a variable size array in the structure. This form is even referenced with the same syntax! Putting the variable array in the structure eliminates a pointer dereference thereby gaining some speed and simplicity of allocation. -- Stuart D. Gathman <..!{vrdxhq|dgis}!bms-at!stuart>