----- Original Message -----
From: "Paul Herring" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, October 15, 2008 4:46 PM
Subject: Re: [c-prog] clrstr()
> On Wed, Oct 15, 2008 at 6:50 PM, andrew clarke <[EMAIL PROTECTED]> wrote:
>
>> char s[100];
>> s[0] = '\0';
>>
>> Or if you wanted to zero every element of the string, the portable way
>> is to use memset():
>
> my_zerostring(s);
>
> /* ... */
>
> void my_zerostring(char* s){
>> memset(s, '\0', sizeof s);
> }
>
> Might be portable, but not guaranteed to work.
>
>
This is what I would do myself.
char s[100];
char a='\0';
int i;
for (i=0;i!=100;++i)
s[i]=a;
Hope that's right.
Bill