I realized that in c++ I cannot initialize an array of double
with memset
. For an integer array I can easily initialize the array using:
int* a = new int[n];
memset(a, n*n, n*sizeof(int));
But how can I initialize an array of doubles in c++?
long double* d = new long double[n];
memset(d, n*n, n*sizeof(long double)); // does not work