----- Original Message ----- 
From: "Brett McCoy" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, June 08, 2008 8:42 AM
Subject: Re: [c-prog] Re: verifiying input


> On Sun, Jun 8, 2008 at 4:29 AM, John Matthews <[EMAIL PROTECTED]> wrote:
>> --- In [email protected], "Brett McCoy" <[EMAIL PROTECTED]> wrote:
>>>
>>> you need to allocate memory for char
>>> *input. And as I said before, buf[] is unnecessary. Create a #define
>>> like BUFSZ 10 and use that to allocate the memory using malloc, and
>>> remember your buffer needs to be BUFSZ + 1 to hold the terminating
>>> '\0'.
>>
>> Just wondering why you need to use malloc()? Eg.
>
> You don't need top use malloc() if you create an array, of course, but
> he was using a pointer and failed to allocate memory for it, so I was
> addressing that.
>
    So Bret buffers don't hold the null string literal terminator ? I don't 
know I've never really thought about it. I know strlen doesn't include it. I 
could've written a little code giving me the strlen of the string but if you 
know I'll just ask you. char arrarys will not by default include '\0' then? 
What about puts ?

Bill

Reply via email to