Error with array in C - arduino

0

I'm having an error signing an array:

Menu m = Menu();
m.Options[4] = {"teste1","teste2","teste3","teste4"};//Erro aqui
m.Show();

Menu Class:

class Menu
{
public:
    String Options[];
    int index = 0;
    int len = 0;
    String Show()
    {
        while(controller.Button == 0)
        {
        len = sizeof(Options)/sizeof(Options[0]);
            index = index + controller.Left;
            if (index < 0)
            index = len;
            if (index > len)
            index = 0;
            display.setCursor(0,00);
            Clear();
            display.println(Options[index]);
            DrawBuffer();
        }
        return Options[index];
    }
 };

I already tried: m.Options[] = {"teste1","teste2","teste3","teste4"}; and m.Options = {"teste1","teste2","teste3","teste4"}; , It also did not work. Home This is the error: no match for 'operator=' (operand types are 'String' and '<brace-enclosed initializer list>')

I'm a beginner in C.

    
asked by anonymous 23.12.2017 / 15:09

1 answer

1

You can not set a fixed size for a dynamic array explicitly. It is a rule of arrays for both C and C ++

Ex of errors:

int array[]; //eu sou dinâmico

main(){
   array[4] = {1,2,3,4}; //definindo tamanho para um array dinâmico? isso tá errado :/

cin << array; //recebendo valores de forma dinamica

Maybe this is possible array[]= {valores};

I have not worked with arrays in a long time, but I remember that rule.

    
23.12.2017 / 15:28