avr@mtgzz.att.com (a.v.reed) (01/06/89)
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)