Can I chain arrays?

OK, I still learn how to code Arduino micro controllers.
And I practically speak no C++.
Anyway ... I have the code of:

  byte a[]={B01111110,B10001000,B10001000,B10001000,B01111110,B00000000};
  byte r[]={B00010000,B00100000,B00100000,B00010000,B00111110,B00000000};

Which I try to copy in a new array

ala byte text[]={a,r}; ... which does not have the wanted result, tho.

I already learned that in C++ handling array is a lot harder than in other languages ... that I can't simply add values to an array ... or copy one array into another ...
How do I do that?

You simply create a new array, that has enough capacity to hold the contents of both array a and r. As both are of size 6, you need at least 12 free entries in the array.

byte text[12];

Then you copy each array separately to the new array

for(uint8_t i = 0; i < 6; i++)
{
    text[i] = a[i];
}

for(uint8_t i = 0; i < 6; i++)
{
    text[6+i] = r[i];
}

Have you tried

  byte text[2][]={{B01111110,B10001000,B10001000,B10001000,B01111110,B00000000},
                  {B00010000,B00100000,B00100000,B00010000,B00111110,B00000000}};

PaulRB:
Have you tried

  byte text[2][]={{B01111110,B10001000,B10001000,B10001000,B01111110,B00000000},

{B00010000,B00100000,B00100000,B00010000,B00111110,B00000000}};

Won't work. This will:

byte text[][6] = {{B01111110, B10001000, B10001000, B10001000, B01111110, B00000000},
  {B00010000, B00100000, B00100000, B00010000, B00111110, B00000000}
};

PaulRB:
Have you tried

  byte text[2][]={{B01111110,B10001000,B10001000,B10001000,B01111110,B00000000},

{B00010000,B00100000,B00100000,B00010000,B00111110,B00000000}};

Not an option. Idea is to define letters and symbols (to be displayed on a matrix) and then chain those together to have the data to display a (scrolling) text.

LightuC:
You simply create a new array, that has enough capacity to hold the contents of both array a and r. As both are of size 6, you need at least 12 free entries in the array.

byte text[12];

Then you copy each array separately to the new array

for(uint8_t i = 0; i < 6; i++)

{
   text[i] = a[i];
}

for(uint8_t i = 0; i < 6; i++)
{
   text[6+i] = r[i];
}

Well tried that my way ... (before your post ... but also gotten nowhere)

  char text[]="ar";
  int flen=(sizeof(text)/sizeof(*text))*6;
  for (int i=0; i<= (sizeof(text)/sizeof(*text));i++ ) {
    for (int j=0; j<= (sizeof(text[i])-1);j++ ){
      byte textBin[flen]=text[i][j];
    }
  }

thaaat_guy:
Well tried that my way ... (before your post ... but also gotten nowhere)

  char text[]="ar";

int flen=(sizeof(text)/sizeof(*text))*6;
  for (int i=0; i<= (sizeof(text)/sizeof(*text));i++ ) {
    for (int j=0; j<= (sizeof(text[i])-1);j++ ){
      byte textBin[flen]=text[i][j];
    }
  }

That code won't even compile. "text" is not a 2-dimensional array, so you can't use 2 subscripts. "textBin" is a local variable to the inner 'for' loop. It will go out of scope and existence as soon as that loop ends.

thaaat_guy:

  char text[]="ar";

// ...
  byte textBin[flen]=text[i][j];

This will not even compile [edit: better explained by gfvalvo] ... Have you actually tried the example I have given?

You should probably rethink your approach. If you already have the data in different arrays, then copying them to another one simply doubles your memory usage without adding any value. Either figure out how to use them as separate arrays for you application or how to have them in a single array in the first place.

LightuC:
This will not even compile [edit: better explained by gfvalvo] ... Have you actually tried the example I have given?

As I said I didn't since I need that as dynamic. Also a lot more than two chars I had here as example.
Basically:

  byte a[6]={B01111110,B10001000,B10001000,B10001000,B01111110,B00000000};
  byte r[6]={B00010000,B00100000,B00100000,B00010000,B00111110,B00000000};
  byte d[6]={B11111110,B00010010,B00100010,B00100010,B00011100,B00000000};
  byte u[6]={B00111110,B00000100,B00000010,B00000010,B00111100,B00000000};
  byte i[6]={B00000000,B00000010,B10111110,B00100010,B00000000,B00000000};
  byte n[6]={B00011110,B00100000,B00100000,B00010000,B00111110,B00000000};
  byte o[6]={B00011100,B00100010,B00100010,B00100010,B00011100,B00000000};
  char text[]="ardunino";
  int flen=(sizeof(text)/sizeof(*text))*6;
  for (int i=0; i<= (sizeof(text)/sizeof(*text));i++ ) {
    for (int j=0; j<= (sizeof(text[i])-1);j++ ){
      byte textBin[flen]=text[i][j];
    }
  }

LightuC:
Then you copy each array separately to the new array

...using the function memcpy

gfvalvo:
You should probably rethink your approach. If you already have the data in different arrays, then copying them to another one simply doubles your memory usage without adding any value. Either figure out how to use them as separate arrays for you application or how to have them in a single array in the first place.

Thing is I want to define Letters A-Z and some special chars & graphics as seen above. As data which then can be send to a 8 by 8 led matrix.
And then have a String which defines of which binary data above is send in which order to the display.
I also want to scroll it across the dotmatrix ... I think (and I might be wrong) having one array with all the information and then walk through it step by step to send each frame (again a frame might contain some of one char and some of another) is the solution ...

AWOL:
...using the function memcpy

memcpy? is that build in?

Maybe something like this?

 /********************************************************************************
    This data structure represents one frame. 
 ********************************************************************************/
 struct frame_t
 {
    char symbol;
    byte content[6];
 };
 
 /********************************************************************************
    This is the array storing all the possible frames. The symbol field in 
    the frame_t data structure is used to map the frame to the symbol it 
    represents. 
    
    Example: A is represented by {0x7E, 0x88, 0x88, 0x88, 0x7E, 0x00}
            <frame_t>.symbol = 'A';
            <frame_t>.content = {0x7E, 0x88, 0x88, 0x88, 0x7E, 0x00};
  *******************************************************************************/
 frame_t frameMap[] = {
    {'A', {B01111110,B10001000,B10001000,B10001000,B01111110,B00000000}},
    {'r', {B00010000,B00100000,B00100000,B00010000,B00111110,B00000000}},
    // define more characters or frames
 };
 
 /********************************************************************************
    This functions retrieves a frame from the map. It uses the symbol field
    in the frame_t structure to find the correct frame in the map. It returns
    either a pointer to the frame or a nullptr, if no frame could be found in 
    the map.
 ********************************************************************************/
 frame_t* getFrameFromMap(char value)
 {
    uint8_t mapSize = sizeof(frameMap) / sizeof(frame_t); 
    
    for(uint8_t i = 0; i < mapSize; i++)
    {
        if(frameMap[i].symbol == value)
        {
            // found the mapping
            return &frameMap[i];
        }
    }
    
    // no frame found
    return nullptr;
 }
 
 
 /********************************************************************************
    Call this function when you want to display a text. It will iterate over 
    the text and display each character. For this, it gets the frame 
    representing the character using the getFrameFromMap function.
    
    The scrollSpeed controls how long the character is shown.
 ********************************************************************************/
 void showText(const char* text, float scrollSpeed)
 {
    while(*text != '\0')
    {
        frame_t* frame = getFrameFromMap(*text++);
        if(frame == nullptr)
        {
            // do error handling, character was not in the map
        }
        else
        {
            displayFrame(frame);
        }
        delay(200 * scrollSpeed);
    }
 }

I haven't had the chance to test or compile it, but you can use it to implement your version.
Basically you'll have an array of frames. Each frame, is mapped to a corresponding symbol or character in the frameMap array. The function showText uses the helper function getFrameFromMap(char) to get a frame from the frameMap, that represents the character that should be shown on the display.

The rest of the could should be pretty self-explanatory, be aware of the delay in the showText function though. To compile this you will need to have a function

void displayFrame(frame_t* frame)
{
  // send the frame to the display as you've already implemented
  // you can access the data through frame->content.
}

gfvalvo:
Won't work. This will...

Oops. Thanks, you're quite right.