From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <764fc0b0ab4cc1f9a890bc61a61a7c81@ladd.quanstro.net> References: <0522651bfa90c83ddb192a77ddaccb78@swcp.com> <460c4983c43135098e3c1f2b36623833@swcp.com> <764fc0b0ab4cc1f9a890bc61a61a7c81@ladd.quanstro.net> Date: Thu, 29 Jul 2010 08:11:26 -0700 Message-ID: From: David Leimbach To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=00163646c264f5339c048c8825d6 Subject: Re: [9fans] writing to ctl using fprint and write Topicbox-Message-UUID: 44c655d4-ead6-11e9-9d60-3106f5b1d025 --00163646c264f5339c048c8825d6 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Jul 29, 2010 at 8:04 AM, erik quanstrom wrote: > > Thanks Erik, Sape, and Skip. That was such a STUPID error, and I thank > > you all for the extra eyes. I think it is time for a break and a bowl of > > tea... > > relax. not stupid, subtle. it takes vigilance to keep > sizeof, nelem, strlen, and the number of characters > straight. > > - erik > > And you *can* use sizeof on arrays :-). Well at least in ANSI/ISO C. Haven't tried this on plan 9. :-) On my mac I get 6 and 8. #include char blah [] = "Hello"; char * blah2 = "There"; int main () { printf("sizeof blah: %ld\n", sizeof(blah)); printf("sizeof blah2: %ld\n", sizeof(blah2)); } --00163646c264f5339c048c8825d6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Thu, Jul 29, 2010 at 8:04 AM, erik qu= anstrom <quan= stro@quanstro.net> wrote:
> Thanks Erik, Sape, and Skip. =A0That was such a STUP= ID error, and I thank
> you all for the extra eyes. =A0I think it is time for a break and a bo= wl of
> tea...

relax. =A0not stupid, subtle. =A0it takes vigilance to keep
sizeof, nelem, strlen, and the number of characters
straight.

- erik


And you *can* use sizeof on arr= ays :-).

Well at least in ANSI/ISO C. =A0Haven'= ;t tried this on plan 9. =A0:-)

On my mac I get 6 = and 8.

#include <stdio.h>

= char blah [] =3D "Hello";
char * blah2 =3D "There&= quot;;

int main =A0() {

= =A0=A0 =A0 =A0 =A0printf("sizeof blah: %ld\n", sizeof(blah));
=A0=A0 =A0 =A0 =A0printf("sizeof blah2: %ld\n", sizeof(blah2= ));

}

=A0

--00163646c264f5339c048c8825d6--