Zero Length Arrays Allowed in C Standard?

David Battle battle at alphard.cs.utk.edu
Thu Dec 14 07:57:35 AEST 1989


In article <70188 at psuecl.bitnet> c9h at psuecl.bitnet (Charles Hannum) writes:
>It seems that the main reason (and *only* even half-way decent reason) for
>using a 0-length array is to allocate a variable amount of memory for a
>structure depending on the length of the array.  This seems reasonable.

Is the order of elements of a structure guaranteed to be the same in memory
as in the program?  That is, given:

struct foo {
    int a;
    int b;
};

struct foo bar;

Is &bar.a guaranteed to be < &bar.b?

					-David L. Battle
					 battle at battle.esd.ornl.gov
					 battle at utkux1.utk.edu



More information about the Comp.lang.c mailing list