Hello out there.
I have the problem that a function should pass an array - impossible - , better: a reference to it (?). I don't get any further.
this is the current code:
void setup () {
Serial.begin (115200);
delay(750);
const byte macAddr[] = {0x28, 0xFF, 0x64, 0x1E, 0x5E, 0x6C};
doIt(macAddr, 6);
}
void doIt(const byte nameOfArray[], const int sizeOfArray) {
Serial.println("do it :");
byte returnArray[6];
for(int i=0; i < sizeOfArray; i++) {
returnArray[i] = nameOfArray[i] + 13;
Serial.print(nameOfArray[i], HEX);
Serial.print("(old), ");
Serial.print(returnArray[i], HEX);
Serial.println(" (new)");
}
////
Serial.println("\nTEST starting...");
auto& test = returnArray;
for(int j=0; j < sizeOfArray; j++) {
Serial.println(test[j], HEX);
}
Serial.println("...ending");
////
}
void loop() {
// do nothing
}
now I would like to return the variable 'test' using 'return' so that I can use the modified array in the main code later. I'm stuck there and can't get any further.
Since I'm a beginner, I'm not at all familiar with pointers and references, and I don't want to go into this in depth at the moment. I'm looking for a solution as quickly as possible.
i'm using an esp32 and the arduino-ide 1.8.19.
with the request for constructive and further help. (please no cryptical pseudocode - i'm a beginner, thanks)
thanks in advance