I have a couple static global arrays, and I need to conditionally set an array inside my function to be equal to one of them under certain conditions.
static int arr1[] = {1,2,3,4};
static int arr2[] = {4,3,2,1};
int myFunc(int x) {
int myArr[4];
if (x > 4) {
myArr = arr1;
}
else if (x <= 4) {
myArr = arr2;
}
}
I'm getting error: incompatible types in assignment and the only thing I can guess is that the static keyword is interfering, because as far as I can tell, both sides of the assignment are int[].
Thanks in advance!