r/codefights • u/Shot_Accountant_8613 • Nov 16 '20
stuck on Arcade question 4
I get an error that says:
main.c: In function ‘adjacentElementsProduct’:
main.c on line 19:30: error: subscripted value is neither array nor pointer nor vector
for(i = 0; i < inputArray[i] != '\0'; i++){
^ main.c on line 20:29: error: subscripted value is neither array nor pointer nor vector
product = inputArray[i] * inputArray[i + 1];
^ main.c on line 20:45: error: subscripted value is neither array nor pointer nor vector
product = inputArray[i] * inputArray[i + 1];
// Arrays are already defined with this interface:// typedef struct arr_##name {// int size;// type *arr;// } arr_##name;//// arr_##name alloc_arr_##name(int len) {// arr_##name a = {len, len > 0 ? malloc(sizeof(type) * len) : NULL};// return a;// }////int adjacentElementsProduct(arr_integer inputArray) {
int i;int product = 0;int largest_product = 0;
for(i = 0; i < inputArray[i] != '\0'; i++){
product = inputArray[i] * inputArray[i + 1];if(product > largest_product){
largest_product = product;}}return largest_product;}