I'm trying this simple example to populate a floating point array with 5.6, but upon printing the values out, every value is just 0.0.
#include <string.h>
float testArr[20];
memset(testArr, (float)5.6, 3*sizeof(float));
printf("Value 1: %lf\n",testArr[0]);
printf("Value 2: %lf\n",testArr[1]);
printf("Value 3: %lf\n",testArr[2]);
printf("Value 4: %lf\n",testArr[3]);
I've also tried not casting 5.6 as a float, setting testArr[20] = {} and testArr[20] = {0}, but they also result in the same 0.0.
memset()and then search for floating-point to integer conversion. None of them are magic.forloop, notmemsetmemsetconverts the second parameter to a char. See memset - C++ Reference.