I read allready about some ways like doing this for known amount of values like:
new int[3] {0 , 0, 0};
After this remembered me of the way of initializing arrays on declaration in C
I asked my self about it is also valid in C++
to do this:
new int[n] {}
Where the empty Braces cause everything to be 0
-initialized.
After trying out it looks fine to me, but could also just be caused by randomness and in real UB or something.
And if it is valid, are there also ways to init on a specific value?
note:
I want to achieve the same as a call to calloc (n, sizeof(int));
would do. But since I'm now in C++
and not C
anymore I won't use theese functions anymore to keep the code readable.
note2:
When saying
I want to achieve [...]
It is corresponding to my minimal example, at all I just want to obtain a zero initialized block of valid memory.