Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Don't understand sizeof char* array Date: Tue, 09 Aug 2011 21:41:10 +1200 Lines: 11 Message-ID: <9acdlmFv2pU5@mid.individual.net> References: <925ae74e-7c1e-401e-908e-36a2760f362b@y16g2000yqk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net x35dNviIjtuk7qnAVkUFxQR3TMs80ESj/Y+x7Sz3hS5E7TxHt4 Cancel-Lock: sha1:bcKH/JZSveeNk1hZ1s6vVgGcaqE= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: <925ae74e-7c1e-401e-908e-36a2760f362b@y16g2000yqk.googlegroups.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:8583 On 08/ 9/11 09:34 PM, Angus wrote: > I have this array: > char* s[] = {"cat", "cat", "dog", "mouse", "rat"}; > int sz = sizeof(s); // 20 why 20??? > > I would expect sizeof to report 17. Why is it reporting 20? On your system, sizeof(char*) = 4 and you have 5 in the array. -- Ian Collins