How can you initialize all elements with a value using this formula (not memset)?
With a loop. You cannot do this in a smart and portable way with memset .
float myArray[myArraySize] = {1}; for (size_t i=0; i<myArraySize; i++) myArray[i] = 1.;
It may seem ugly, but it's the C path (and it gets prettier if you rename myArraySize to something like N ). Alternatively, if the number of elements is fixed, you can simply list the array and optionally leave the size:
float myArray[] = {1., 1., 1., 1., 1., 1.};
Fred foo
source share