On Thursday, 4 June 2015 at 17:25:52 UTC, Alex Parrill wrote:
On Thursday, 4 June 2015 at 17:04:06 UTC, jmh530 wrote:
float output[len];
This creates a fixed-sized array of length `len` (using the
deprecated syntax). Since the length is part of the type, it
needs to be known at compile time.
You probably want a dynamic array instead. `auto output = new
float[len]`
Also note that you're not seeding your random number generator,
so it will produce the same sequence every time. You probably
want `auto gen = Random(unpredictableSeed);`
Thanks for the reply. Changing to a dynamic array works. I think
I need to read a bit more on the difference between static and
dynamic arrays. It seems like you avoid some of these issues if
you pass the array that you want to fill up into the function. I
could pass either a static or dynamic array in that case.
On the seeding thing, I know that it was doing that, I just
wanted to focus on the part that wasn't working.