Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!lll-winken!unixhub!ditka!comeau From: comeau@ditka.Chicago.COM (Greg Comeau) Newsgroups: comp.lang.c++ Subject: Re: bug in istrstream example? Message-ID: <38767@ditka.Chicago.COM> Date: 13 May 91 18:46:02 GMT References: <1991May11.015836.1556@neon.Stanford.EDU> Sender: comeau@ditka.Chicago.COM (Greg Comeau) Reply-To: comeau@csanta.attmail.com (Greg Comeau) Organization: Comeau Computing Lines: 19 In article <1991May11.015836.1556@neon.Stanford.EDU> philip@pescadero.stanford.edu (Philip Machanick) writes: > 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? No. The array -> ptr conversion DO NOT occur when an array names is used as the operand of sizeof. The sizeof will return the total number of bytes in s. If s was : char s[] = "12345";, sizeof would return 6. - Greg -- Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Producers of Comeau C++ 2.1 Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421 Voice:718-945-0009 / Fax:718-441-2310