#define MAX 100
double velocity[MAX];
for (itr = 0; itr < velocity[0]; itr = itr + 1)
{
velocity[itr] = velocity[0] - (1*itr);
distance[itr] = rk4_solve(itr, velocity);
cout << setw(5) << itr << setw(9) << velocity[itr] << setprecision(4) << setw(10) << distance[itr] << endl;
}
I am trying to input values into the array but for some reason I get the error: i Invalid types 'double [100][double]' for array subscript for the 3 lines inside the for loop.
itr
must be anint
(or other integer type)Be aware that you are comparing
itr
withvelocity[0]
in the for cycle (itr < velocity[0];
). You probably meantitr < MAX
, and I hope somewhere you defined the variableitr
Just had a similar issue.
Array index's cannot be double or float.
I fixed my issue by typecasting the index's to int.
A total shot in the dark, but could you be missing a semicolon just above the lines shown?