Hello all
I've got stuck on something which might have a very simple solution. I'd like to ask your help.
I've initialized an array as follows:
uint8_t linha[4] = {0,0,0,0};
The idea is to read its terms sequentially inside a loop, as a way to give a specific set of data for each phase in the program. The loop is ok, working fine. No trouble for reading every term one at once.
I've been finding hard time to attribute values to this array. I want to attribute all at once, just like a set of values according to each phase. Nevertheless, I haven't found the right syntax to make it happen.
1st example:
case 5: linha[] = { 24, 5, 6, 27 }; break;
returns error: expected primary-expression before ']' token
2nd example:
case 5: linha[4] = { 24, 5, 6, 27 }; break;
returns error: cannot convert '' to 'uint8_t {aka unsigned char}' in assignment
The only one to make it work has been:
case 5: linha[0]=24; linha[1]= 5; linha[2]= 6; linha[3]=27; break;
It doesn't sound very efficient. There must be any better way. Let's think about an array with 25 parameters. How many lines it would take, how much time to type it all? It would be at least confusing to read latter.
Any better idea?
Thank you.
Regards, Ciro.