Regarding the code below, is there a way to initialize arr0[] and arr1[] to match one of the other two arrays chosen by the input parameter? Or is it possible to make arr0[] and arr1[] a constant array? Thanks.
#define LENGTH 4
void foo(char id) {
const char arr_a0[] = {2,1,2,1};
const char arr_a1[] = {4,5,6,7};
const char arr_b0[] = {3,3,3,4};
const char arr_b1[] = {1,5,8,9};
char arr0[LENGTH];
char arr1[LENGTH];
int i;
switch(id) {
case 'a':
for (i = 0; i < LENGTH; ++i) {
arr0[i] = arr_a0[i];
arr1[i] = arr_a1[i];
}
break;
case 'b':
default:
for (i = 0; i < LENGTH; ++i) {
arr0[i] = arr_b0[i];
arr1[i] = arr_b1[i];
}
break;
}
/* Do something with arr0[] and arr1[] */
}