total space of a string (was: hardcoded constants)

Guy Harris guy at auspex.UUCP
Thu Dec 22 03:57:24 AEST 1988


>"/" is a pointer to a string containing a '/' and a '\0'.

"/" is not a pointer to a string; it is the string (i.e. an array of
"char") itself.  In some, but not all, contexts, the array is converted
to a pointer to its first member; "argument of 'sizeof'" is not one of
those contexts.  (Check your K&R, or your dpANS.)

>Therefore it seems to me that sizeof "/" will return the same value as 
>sizeof( char * ).  

This is, alas, apparently a mistake made by some C implementors; with
any luck, there'll be a conformance-testing suite for the ANS when it
comes out, and it will catch errors such as that. 



More information about the Comp.lang.c mailing list