www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Does 'new' fill the memory.

reply Questiom <Questiom_member pathlink.com> writes:
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?
Sep 30 2005
next sibling parent bobef <bobef lessequal.com> writes:
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).
Sep 30 2005
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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).
Sep 30 2005
parent reply Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
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.
Oct 01 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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.
Oct 01 2005