send array values from CPP to main loop

I’ve been working on my Arduino skills lately and I must say that I don’t disappoint myself. However, now I ran into a problem I don’t manage to solve.

I’m receiving modbus messages over an ESP8266. So far so good. Then I translate the Hex codes to ASCII and then a string. Also no problem.
But here it comes: The function that I can use to send the received text to the serial monitor, runs in the ModbusTCP.CPP file.

void ModbusTCP::printMB(char *s, int n) {

  int i;

  for (i = 17 ; i < n;) {

My OLED display is being controlled from the main (void) loop like this:

void loop(void)
  // Process MODBUS requests on every scan;

    display.println("MODBUS values");

So now I need a way to take the values that I can display in the serial monitor to the main sketch, where I can then prnt them on the OLED display.

Does anyone have a clue how this is possible?
I already tried to make the array mb_adu a global variable, but that doesn’t work…

Thanks in advance for your help!

Create the buffer in your sketch then pass it to the printMB function, which puts the message in that buffer:

void setup() {
  while (!Serial) {}
  char buffer[8];

void loop() {}

void fillBuffer(char buffer[]) {
  strcpy(buffer, "message");