This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: signed/unsigned char
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Milena Constantino Caires <milena at registro dot br>, gcc-help at gcc dot gnu dot org
- Date: Wed, 20 Jul 2005 09:57:40 -0500
- Subject: Re: signed/unsigned char
- References: <20050720144555.GA63554@registro.br>
Hi Milena,
> char* c = new char(1024);
This allocates a single character, initialized with the value 1024. (Since 1024 is bigger than what a char can hold on most systems, it will get sliced.)
>I know that the correct form of this memory allocation is "[1024]" and not "(1024)" but sometimes it occurs by mistake.
Both forms are correct.
You can allocate an array of char.
You can allocate a single char.
>The compiler is not supposed to complain about it???
No, there is nothing to complain about. You are allowed to allocate a single object.
HTH,
--Eljay