Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8583
| 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 <ian-news@hotmail.com> |
| 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> (permalink) |
| 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 |
Show key headers only | View raw
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
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Don't understand sizeof char* array Angus <anguscomber@gmail.com> - 2011-08-09 02:34 -0700
Re: Don't understand sizeof char* array Ian Collins <ian-news@hotmail.com> - 2011-08-09 21:41 +1200
Re: Don't understand sizeof char* array Juha Nieminen <nospam@thanks.invalid> - 2011-08-09 11:30 +0000
Re: Don't understand sizeof char* array Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-09 08:48 -0400
Re: Don't understand sizeof char* array gwowen <gwowen@gmail.com> - 2011-08-10 01:23 -0700
Re: Don't understand sizeof char* array Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-10 09:00 -0400
Re: Don't understand sizeof char* array Immortal Nephi <Immortal_Nephi@hotmail.com> - 2011-08-10 18:17 -0700
Re: Don't understand sizeof char* array Paavo Helde <myfirstname@osa.pri.ee> - 2011-08-11 00:30 -0500
csiph-web