Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!aplcen!haven!wam!dkim From: dkim@wam.umd.edu (Daeshik Kim) Newsgroups: comp.lang.c Subject: Re: another stupid array/pointer question Message-ID: <1990Mar3.043244.17793@wam.umd.edu> Date: 3 Mar 90 04:32:44 GMT References: <1990Mar2.135645.17274@granite.cr.bull.com> Sender: usenet@wam.umd.edu (USENET Posting) Reply-To: dkim@wam.umd.edu (Daeshik Kim) Organization: Univ. of Md, College Park Lines: 37 In article <1990Mar2.135645.17274@granite.cr.bull.com> freedman@granite.cr.bull.com (Jerome Freedman) writes: > >Suppose I have a structure > > struct a { > char * a_string; > } > >and a structure > > struct b { > char another_string[80]; > } > > sizeof(struct a) should equal sizeof(char *) > > but what about sizeof(struct b)? > Is the 80 character array included in the size of struct b or > is b.another_string a pointer into somewhere where there is > allocated space - is this implementation defined? > As far as I know, 'struct a' only has a space for 'ptr'; but 'struct b' holds 80 bytes statically allocated. In most c-compilers, I would say that if you have: struct b str; /* now, allocated. */ if you refer str, the address of 'str' should be same as the address of 'str.another_string[0]', which means that str and str.another_string points same location. I haven't seen c-compilers with other strategy yet. -- Daeshik Kim H: (301) 445-0475/2147 O: (703) 689-5878 SCHOOL: dkim@wam.umd.edu, dskim@eng.umd.edu, mz518@umd5.umd.edu WORK: dkim@daffy.uu.net (uunet!daffy!dkim)