This array represents a configuaration, i want to change this configuration to numerous other ones depending on a user choice.
What's the fastest way to do this? The following code didn't work but represents what i want to do:
My first idea was to write all configs in variables and simply move the pointer to the active one. But the last time i used C is long ago so i have no clue how to do it.
The following code didn't work but represents what i want to do:
If you want to set the contents of one array to the contents of another array, and both arrays are the same size and type, memcpy() would be useful.
If you have two arrays, configOne and configTwo, you can have a pointer:
byte configOne[] = {1,2,3,4,5};
byte configTwo[] = {6,7,8,9,10};
byte *configPtr = configOne; // Use configuration 1
.
.
.
byte one = configPtr[2]; // one will be 3
.
.
.
configPtr = configTwo; // Change to configuration 2
.
.
.
one = configPtr[2]; // one will be 8
My first idea was to write all configs in variables and simply move the pointer to the active one. But the last time i used C is long ago so i have no clue how to do it.
If you're going to do that, why not use a 2D array and keep a variable with the currently selected row in it?