I can't manage to use a variable as index for my array

int sum = 3;
int i = 0;
myCode[] = {};
void loop () {
  myCode[i] = sum;
}

In this example the variable 'i' gets the value of '3' instead of assigning the value of '3' to the array myCode[] with the index '0' (i).

I honestly don't know why it does this. This is only a small part of the program. I don't include the full program because that would only be confusing for you guys and this is the only part of the program that is not working.

How would I use the value of i to assign a value to the array with i as index??

On another forum someone helped me with this
SOLUTION: I should put the max length for the array between the ;
I wanted the array myCode to have max 4 integers so I changed it to:

int myCode[4] {};

Have a look at your other thread ;)

How would I use the value of i to assign a value to the array with i as index??

myCode[i] = someValue;

This:

myCode[] = {};

creates an array with zero elements. So, where do you think you’re actually putting the data?

Regards,
Ray L.