[RESOLVED] Need to define a group of bytes, two different ways.

This is an easy question. I just don't know how to look it up:

I want to be able to use the SAME char array two different ways.

As a list of seventy 8-character names:

char micNames[70][9];

And also as a simple array of characters:

char micNames[630];

What's the technique for defining one item two ways?

union

Using a union will work, but is completely unnecessary. The easiest way is using a pointer. A pointer can be used to point to different sized arrays:

char buf[70 * 9];
char *ptr = buf;

Using ptr[0] through ptr[629] will address buf as a one dimensional array
Using ptr[0][0] through ptr[69][8] will address buf as a two dimensional array

Regards,
Ray L.

Thank you guys, both of you!

I see the second way is simpler, but it's a bit too simple for me, leaving too much in the abstract, to be imagined and remembered.

I went with the first way, "union", because it allows me to see what's happening better; and wrote:

union micF
{
  char Names[70][9];
  char Chars[630];
} micF;

// EXAMPLE USING ".Chars":

  for (i=0; i<360; i++)
      micF.Chars[i] = EEPROM.read(i+200);

// EXAMPLE USING ".Names":

strcpy(fNames[i],micF.Names[lastFileRead]);

Googling "C++ union", I found the perfect explanation and example at
Tutorials Point: C - Unions.

Thank you for the follow-up.