This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: signed/unsigned char


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]