Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!nosc!ucsd!rutgers!att!mtuxo!mtgzy!mtgzz!avr From: avr@mtgzz.att.com (a.v.reed) Newsgroups: comp.windows.x Subject: Sizeof (was Re: stupid C question) Summary: ANSI says 6 Message-ID: <4838@mtgzz.att.com> Date: 5 Jan 89 22:04:14 GMT References: <8812300028.AA17754@EXPO.LCS.MIT.EDU> Organization: AT&T, Middletown NJ Lines: 12 In article <8812300028.AA17754@EXPO.LCS.MIT.EDU>, rws@EXPO.LCS.MIT.EDU (Bob Scheifler) writes: > #define foo "abcde" > Is sizeof(foo) defined to be 5, 6, or >=5? My Sun compiler gives 6, > I have a bug report claiming it should be 5, and the C manuals I have > are no help. The ANSI standard (paragraph A7.4.8 in the Jan 11, 1988 draft) says: "The sizeof operator yields the number of bytes required to store an object...." Since the number of bytes required to store "abcde" is 6 (remember the '\0' required to terminate the string), your compiler is correct. Adam Reed (avr@mtgzz.ATT.COM)