I naively thought I could use memset for this, but apparently memset is only for chars. Is there a memset-type thing that will work on an array of floats? Or is simple iteration the fastest way to copy a single value to every spot in an array?
Share
I won’t speak to what code runs the fastest. You should compare them yourself, in the intended environment.
But, here are two readable, maintainable, correct solutions.
Or, if you have a dynamic array: