Hi!
I'm new into C programming and Arduino.
I'm trying to display some data on several 7LED Digit Displays but I get this error and I don't know why.
This is my code:

int iasDigits[] = {0, 1, 2}; 

void sendToDisplay(unsigned int device, int digits, char value, unsigned int valueLength){
for(int i = 0; i < valueLength; i++){
  lc.setDigit(device, digits[i], value[i], false);
}
}

And this is how I call the function:

sendToDisplay(0, *iasDigits, intToChar(iasValue, IAS_LENGTH), IAS_LENGTH);

intToChar returns an array with all the integer digits in order to display them one by one.
iasDigits value sets the address where each value will be displayed.

So, when I'm trying to read the address from digits[i] array I get this error:

error: invalid types 'int[int]' for array subscript

error: invalid types 'char[int]' for array subscript

Same happens with value[i] array.

In your function sendToDisplay, the object named digits is a single int.

So what are you trying to do here: digits[i] ? Digits is an int. Not an array. Likewise for value. value is a single char. Not an array.

I'm trying to pass this array
int iasDigits[] = {0, 1, 2};
to sendtoDisplay function

Pass a pointer to the first member of the array.

void sendToDisplay(unsigned int device, int* digits, char* value, unsigned int valueLength){
for(int i = 0; i < valueLength; i++){
lc.setDigit(device, digits[i], value[i], false);
}

called like this

sendToDisplay(0, iasDigits, intToChar(iasValue, IAS_LENGTH), IAS_LENGTH);

If intToChar really does return a char array (or rather, something that decays to a char-pointer) it will work fine.

commented: Thank you! +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.