Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ucbvax!ucsfcgl!socrates.ucsf.edu!pett From: pett@socrates.ucsf.edu.UUCP Newsgroups: comp.sys.atari.st Subject: Re: "file selector" blues, Megamax bug Message-ID: <10163@cgl.ucsf.EDU> Date: Mon, 13-Apr-87 18:01:52 EST Article-I.D.: cgl.10163 Posted: Mon Apr 13 18:01:52 1987 Date-Received: Wed, 15-Apr-87 02:58:24 EST References: <639@batcomputer.tn.cornell.edu> <821@viper.UUCP> Sender: daemon@cgl.ucsf.edu Reply-To: pett@socrates.ucsf.edu.UUCP (Eric F. Pettersen) Organization: UCSF Computer Graphics Lab Lines: 32 Keywords: user-friendly C sizeof In article <821@viper.UUCP> john@viper.UUCP (John Stanley) writes: >In article <639@batcomputer.tn.cornell.edu> > braner@tcgould.tn.cornell.edu.UUCP (braner) writes: > >Yet another bug in Megamax C: > > > > sizeof("a string constant") always yields 4. > > > > (sizeof(s) where s is of type array-of-char works fine.) > > > >- Moshe Braner > > As I mentioned before... This is infact the right way for sizeof to >work. ... What??? I find it difficult to believe this is a subject for argument! A string constant is a character ARRAY and therefore sizeof returns the storage taken by the string constant. If you have an array: int foo[10][10], sizeof(foo) will return 100 * sizeof(int) despite the fact that foo is a pointer. If you don't believe me just run the following program on your MAINFRAME yourself. #include main() { printf("sizeof(\"abcdef\") = %d\n", sizeof("abcdef")); } This will return 7. Eric Pettersen pett@cgl.ucsf.edu or ucbvax!ucsfcgl!pett