Search code examples
carraysarduinochars

Array of strings (char array) in C (Arduino). How do I accomplish it?


I want to access certain data which basically looks like this:

char* a[]={
    "0000000000",
    "0000000000",
    "0011111100",
    "0000100100",
    "0000100100",
    "0011111100",
    "0000000000",
    "0000000000",
};

I have around 200 of those data sets and want to access it in the way.

fooBar[23]; --> This should return the 23rd character array (which looks like the example listed above).

As far as I understand from my other programming knowledge, I would need an array of Strings. The array index is my lookup number (which will be a maximum of 255). The array values are the character arrays as shown above.

How can this be accomplished with C (Arduino IDE)?


Solution

  • Just use a two dimensional array. Like:

    char a[][]={
        "0000000000",
        "0000000000",
        "0011111100",
        "0000100100",
        "0000100100",
        "0011111100",
        "0000000000",
        "0000000000",
    };