[OCLUG-devel] malloc() woes

Christopher Smith x at xman.org
Sun May 29 12:22:01 PDT 2005


James Colannino wrote:

>James Colannino wrote:
>
>  
>
>>if (buffer[BUFFER_SIZE] != '\n') {
>> 
>>
>>    
>>
>
>By the way, probably not a big deal since this doesn't concern my
>question, but since arrays start at 0, just for the record I'll change
>this to:
>
> if (buffer[BUFFER_SIZE - 1] != '\n') {
>
>or maybe:
>
>if *(buffer + BUFFER_SIZE) != '\n') {
>  
>
If the buffer is filled, buffer[BUFFER_SIZE-1] should equal '\0'. It 
should never be '\n' unless from garbage memory.

--Chris


More information about the OCLUG-devel mailing list