error: invalid types 'int[int]' for array subscript

Hi
I have code

int distance = 400;
int avg_distance = 200;
int *avg_tmp[10] = {300, 200, 200, 200, 200, 200, 200, 200, 200, 200};
int avg_counter = 0;
int tmp_sum = 0;

void loop() {

avg_distance[avg_counter] = 3; //distance;
    if ( avg_counter == 9 )
      avg_counter = 0;
    else
      avg_counter++;


 for ( int i = 0; i < 10; i++)
      tmp_sum += avg_distance[i];

}

why I’m making such a mistake :

error: invalid types ‘int[int]’ for array subscript

  • avg_distance[avg_counter] = 3; //distance;*

and

error: invalid types ‘int[int]’ for array subscript

  • tmp_sum += &avg_distance[3];*

how to correct it ?

Thanks.

avg_distance is NOT declared as an array or pointer so you can't use an index on it.

Thank You
Now it is working

My fault.
I have mistaken two variables with each other : avg_distance and avg_tmp[10] :confused:

If he used the rubber duck method, I would handle it myself

Bye