Hello!
I am trying to crate a 2d char array where one dimension is a line to print to a display and the other dimension is the max length of one line.
The relevant part of the code:
char *content[] = {(char *)"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras nulla justo, iaculis sit amet ipsum at, volutpat sodales leo. In vel metus a quam porttitor tempor. Phasellus volutpat hendrerit urna at volutpat. Aenean eget purus mauris. Nam sollicitudin efficitur neque a sagittis. Vestibulum vitae volutpat nibh. Donec commodo ipsum non enim tincidunt, ac tempor ante commodo.",
(char *)"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii ",(char *)"1 1",(char *)"menuitem4",(char *)"menuitem5",};
char* menucontent[100][21];
void textProcessing() {
int numavailable = 20;
String temp;
char buf[20];
char buf3[20];
int num = 0;
for (int i = 0; i < getFound(menu1[selected], ' '); i++){
temp = getValue(content[selected], ' ', i);
while (temp.length() > 0) {
memset(buf, 0, 20);
if (temp.length() > 20) {
while (temp.length() > 20) {
String buf2 = temp.substring(0,18) + "-";
temp = &temp[18];
buf2.toCharArray(buf,20);
strcpy(menucontent[num], buf);
num++;
}
}
if (temp.length() < 20 && temp.length() != 0){
while (temp.length() < numavailable){
numavailable -= temp.length()+1;
temp.toCharArray(buf3,20);
strcat( buf3, " ");
strcat(buf, buf3);
i++;
temp = getValue(content[selected], ' ', i);
}
strcpy(menucontent[num], buf);
numavailable = 20;
num++;
}
if (temp.length() == 20){
temp.toCharArray(buf,20);
strcpy(menucontent[num], buf); // Is this possible?
num++;
temp = "";
}
Serial.println(menucontent[0]); // Error: "no matching function for call to 'print(char* [21])'"
}
num++;
}
}
The main issue i’m having is that I dont understand how exactly the 2d array works and is it possible to print outh the entire entry?
Thank You in advance!
The entire code for those who are curious(the menu part totally works so feel free to use the code ;)): #include <Encoder.h>#include <SPI.h>#include <Wire.h>#include <Adafruit_GF - Pastebin.com
(Using Adafruit feather m0 so memory is no problem)