limes@sun.uucp (Greg Limes) (04/15/88)
In article <8646@eleazar.Dartmouth.EDU>, major@eleazar.Dartmouth.EDU (Lou Major) writes: > 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. -- Greg Limes [limes@sun.com] frames to /dev/fb
guy@gorodish.Sun.COM (Guy Harris) (04/15/88)
> > 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.