Newsgroups: comp.lang.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!csus.edu!borland.com!pete From: pete@borland.com (Pete Becker) Subject: Re: bug in istrstream example? Message-ID: <1991May13.192455.8475@borland.com> Organization: Borland International References: <1991May11.015836.1556@neon.Stanford.EDU> Date: Mon, 13 May 1991 19:24:55 GMT In article <1991May11.015836.1556@neon.Stanford.EDU> philip@pescadero.stanford.edu (Philip Machanick) writes: >In both Lippman (p. 414) and the cfront 2.0 Library Manual (p 3.12) examples >roughly of the form > char s[] = "400" > istrstream iss (s,sizeof(s)); >appear. Presumably, sizeof is a bug (since this will always return the size of >a pointer when applied to an array), and what is really required is strlen(s) - >or should it be strlen(s)+1 to allow for the null char at the end? > >Has this been fixed in later editions / printings? > >Philip Machanick > The code as written is correct. This is one of the few situations where the name of an array is not converted to a pointer, in both ANSI C and under the ARM. sizoef applied to an array gives the number of bytes in the array! -- Pete