How do I create a dynamic array with real numbers?

  arrays, c++, dynamic

I know the syntax for dynamic arrays with integers, but when I try to create a dynamic array that stores double values, it gives me an error message. (error: expression in new-declarator must have integral or enumeration type)

ifstream f("date.in");
ofstream g("date.out");
double n;
f >> n;
double* v = new double[n];

for(int i=0; i<n; i++)
    f >> v[i];

I usually do

int n;
f >> n;
int* v = new int[n];

and it works.

Source: Windows Questions C++

LEAVE A COMMENT