Quantcast
Channel: How to initialize an array of doubles in c++? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to initialize an array of doubles in c++?

$
0
0

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

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>