comeau@ditka.Chicago.COM (Greg Comeau) (05/14/91)
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