View mode: basic / threaded / horizontal-split · Log in · Help
September 30, 2005
Does 'new' fill the memory.
for example


char []a=new char[55];

Does the 'new' operator fill the array with 0 or can there be some crap in a[]?
I could not find it from specification.

Does anybody know?
September 30, 2005
Re: Does 'new' fill the memory.
Questiom wrote:
> for example
> 
> 
> char []a=new char[55];
> 
> Does the 'new' operator fill the array with 0 or can there be some crap in a[]?
> I could not find it from specification.
> 
> Does anybody know?
> 
> 

Specs says, if I remember correctly, that all variables in D are 
automatically initialized (if they are not void initialized or whatever 
it was called).
October 01, 2005
Re: Does 'new' fill the memory.
"Questiom" <Questiom_member@pathlink.com> wrote in message 
news:dhk1ur$26bt$1@digitaldaemon.com...
> Does the 'new' operator fill the array with 0 or can there be some crap in 
> a[]?
> I could not find it from specification.
>
> Does anybody know?

Yes, it is filled with the type's initializer (in this case 0).
October 01, 2005
Re: Does 'new' fill the memory.
Jarrett Billingsley wrote:
> "Questiom" <Questiom_member@pathlink.com> wrote in message 
> news:dhk1ur$26bt$1@digitaldaemon.com...
> 
>>Does the 'new' operator fill the array with 0 or can there be some crap in 
>>a[]?
>>I could not find it from specification.
>>
>>Does anybody know?
> 
> 
> Yes, it is filled with the type's initializer (in this case 0). 
> 

Char is initialied with 0xFF not 0.
October 01, 2005
Re: Does 'new' fill the memory.
"Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message 
news:dhmaeu$l6g$1@digitaldaemon.com...
> Char is initialied with 0xFF not 0.

Crap.  Forgot about that.
Top | Discussion index | About this forum | D home