I have recently started working with the Arduino (which is C++).
When I run the below function (along with other code):
int index(int val,int list) {
int i;
for (i = 0; i < 8; i++) {
if (val == list[i]) {
return i;
}
return null;
}
}
I get an error on the line if (val == list[i]) {:
invalid types 'int[int]' for array subscript
I have two questions: Why is the error happening, and is there some better way to get the index of a value in an array without using complex syntaxes?
listis anint, not an array. You can't index it like that.int index(int val,int* list)?