Re: string-486.h?

From: Ben Kosse (bkosse@iname.com)
Date: Tue Feb 29 2000 - 03:28:53 EST


> Well the problem is bad 'C' code. It's not the compiler's fault. It's
> just doing what it's told to do.
>
> char str[12]="mystring";
>
> declares a string on the stack with room for 12 bytes. However it is
> initialized with only 9 (8 characters + the implied \0). So the rest
> of the area has to be zeroed, which the compiler does.
No it doesn't. For all C is required to care about, it could be stored as:
"mystring\0bla" The definition is 12 bytes on the stack, the first nine being
"mystring\0".

-- 
Ben Kosse <bkosse@iname.com>

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:21 EST