To access the array indice at the xth position we can use some sort of illustration as shown below
#include<iostream>
using namespace std;
int main(){
float i[20];
for(int j=0;j<=20;j++)
i[j]=0;
}
However the following piece of code does not work
#include<iostream>
using namespace std;
float oldrand[55];
int jrand;
void advance_random(){
int j1;
float new_random;
for(j1=0;j1<=23;j1++){
int temp = j1+30;
new_random = (oldrand[j1]) - (oldrand[temp]);
if(new_random <0.0)
new_random = new_random+1;
oldrand[j1] = new_random;
}
for(j1=24;j1<=54;j1++){
new_random[j1] = oldrand[j1] - oldrand[j1-23];
if(new_random[j1]<0.0)
new_random[j1] = new_random + 1;
oldrand[j1]=new_random;
}
}
I recieve the following error
ga.cpp:20: error: invalid types ‘float[int]’ for array subscript
ga.cpp:21: error: invalid types ‘float[int]’ for array subscript
ga.cpp:22: error: invalid types ‘float[int]’ for array subscript
I am not able to find a mistake in my code please help me