----- Original Message ----- 
From: "andrew clarke" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, October 15, 2008 2:22 PM
Subject: Re: [c-prog] clrstr()

> The parentheses are superfluous.  You only need them if s is a
> datatype.  In most cases where you use sizeof, you're using it to find
> the width of a variable, not a datatype.
>
> Unfortunately code like this is still quite common:
>
> short ara[10];
> memset(ara, 42, sizeof(short));
>
> But what happens if we change ara's datatype, but forget to fix the
> code properly?
>
> long ara[10];
> memset(ara, 42, sizeof(short));
>
> So we should use this instead:
>
> long ara[10];
> memset(ara, 42, sizeof ara);
>
> Regards
> Andrew

    I stand corrected. I now see what you're saying. I've just never used 
sizeof without the parenthesis data type or not.

Bill

Reply via email to