problem with arrays

Hi all:

I have read quite some explenations on the use of arrays
yet i still can not figure out why my code stop when i=101(vc2008 express)


double *cpX;
int size = 10000;
cpX = new double(size);

for(int i = 0; i < size; i++)
{
printf ("%d, %f\n",i, cpX[i]);

}

new double(size);

allocates space for exactly ONE double and initializes its value to 10000.0

new double[size];

allocates space for 10000 doubles and does not initialize their values.

You want the latter, but you are using the former.
Topic archived. No new replies allowed.