Initialize to zero arrays allocated with new
Posted on 2001-08-09
I would like to know an easy way to initialize to zero the arrays(int, long, double,...) created with new
pd_myvar = new double [l_numelements];
Obviously, one way is a loop and going element by element, but I don't want to fill the code with loops just for initialize the arrays.
In C, I used calloc();, and in some cases, memset();, but I'm not sure if the memory allocated by new is guaranteed to be in a continuous memory position.
I'm sure one way is overloading the new operator but I'm afraid of not doing correctly.