Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!oliveb!felix!arcturus!evil From: evil@arcturus.UUCP (Wade Guthrie) Newsgroups: comp.lang.c Subject: Re: Point me in the right direction Summary: how about structs Message-ID: <3735@arcturus> Date: 21 Feb 89 18:26:39 GMT References: <23631@watmath.waterloo.edu> <1841@mit-caf.MIT.EDU> <1043@auspex.UUCP> Organization: Rockwell International, Anaheim, CA Lines: 46 In article <1043@auspex.UUCP>, guy@auspex.UUCP (Guy Harris) writes: [someone started with:] > double fund_consts[] = { > 3.14159265, > 2.7182818, > 6.02E23, > }; [and someone else added:] > Of course, adding: > #define N_FCONSTS (sizeof(fund_consts)/sizeof(double)) [and Guy said:] > So far, so good - this is an old C trick, which is quite useful, but may > not be known as well as it should be - but... [and I say:] This is all well and good, but what about arrays of structures? Am I S.O.L. because of inter-array-element padding if I: struct already_defined snarf[] = {...}; and then try to get the size by doing: #define N_WHATEVER (sizeof(snarf)/sizeof(struct already_defined)) or can I (portably) int size; . . . size = sizeof(snarf)/(&snarf[1]-&snarf[0]); (assuming, of course, that snarf has at least 2 elements. . .) Wade Guthrie evil@arcturus.UUCP Rockwell International Anaheim, CA (Rockwell doesn't necessarily believe / stand by what I'm saying; how could they when *I* don't even know what I'm talking about???)