sizeof behavior (was Bit Addressable Architectures)
Guy Harris
guy at gorodish.Sun.COM
Fri Apr 15 03:26:21 AEST 1988
> > char foo[]="This is a test.";
> > sizeof (foo) == sizeof (char *)
>
> Lou, on my machine (Sun 3/60, SunOS 4.0) this is not true;
> sizeof (foo) == sizeof foo == 16
> This corresponds with the way I have used sizeof with arrays for
> many years now, and in fact the standard unix kernel configuration
> files depend on it. Of course, your mileage may vary, but I would like
> to hear about any machines where sizeof works the way you state.
I'm sure *everybody* would like to hear about any purported C implementations
that work the way he states, because they wouldn't be C implementations.
"foo[]" is an array of characters, and as such in *any* valid C implementation
"sizeof foo" will return the number of "char"s the array takes up, namely 16.
More information about the Comp.lang.c
mailing list