Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!spool.mu.edu!uwm.edu!linac!unixhub!ditka!comeau From: comeau@ditka.Chicago.COM (Greg Comeau) Newsgroups: comp.lang.c++ Subject: Re: size of array Message-ID: <38854@ditka.Chicago.COM> Date: 14 May 91 13:41:39 GMT References: <1991May11.015836.1556@neon.Stanford.EDU> <38767@ditka.Chicago.COM> <1991May13.220553.28817@scrumpy@.bnr.ca> Sender: comeau@ditka.Chicago.COM (Greg Comeau) Reply-To: comeau@csanta.attmail.com (Greg Comeau) Organization: Comeau Computing Lines: 24 In article <1991May13.220553.28817@scrumpy@.bnr.ca> bnrmtl!pat@larry.mcrcim.mcgill.edu writes: >In article <38767@ditka.Chicago.COM>, comeau@ditka.Chicago.COM (Greg Comeau) writes: >|> 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. >I remember once >being confused by an example like this: > void f( char a[10] ) { cout << sizeof(a) << '\n'; } >where the value that got printed was sizeof(char*), not 10. >...that the declaration of a _looks_ like a declaration of an >array, but is actually a declaration of a pointer. This is all of course a C artifact. Yes, that is a pointer and not an array. Parameters work this way. Dimensions provided with parameters are either for documentation (hence with limited use) or for allowing type scaling to happen properly. - 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