Working with String´s List
Posted: Sun Jan 09, 2022 11:54 pm
Hi my friends! Greetings from Cuba. I am trying to use this library <List.hpp> that I found in the library administrator. However, when I try to access to the data that I add to the list, it returns empty. I think that the problem is in the use of pointers, I am not good on it, so please my friends, give me a hand. Thanks!!
This is the code
#include <List.hpp>
void setup() {
Serial.begin(115200);
List <String> list;
String test = " ";
String test1= "item";
for (int i = 0; i <= 5; i++)
{test= test1+i;
String testCopy;
testCopy(test);
list.add(testCopy);
Serial.println(*list[i]);
}
for (int i = 0; i <= 5; i++)
{Serial.print(i);
Serial.println(": ");
if(*list[i]=="item3")
{Serial.println("diferent"); //
}
Serial.println(*list[i]);
Serial.print("Capacity: ");
Serial.println(list.getSize());
}
}
void loop() {
}
This is the code
#include <List.hpp>
void setup() {
Serial.begin(115200);
List <String> list;
String test = " ";
String test1= "item";
for (int i = 0; i <= 5; i++)
{test= test1+i;
String testCopy;
testCopy(test);
list.add(testCopy);
Serial.println(*list[i]);
}
for (int i = 0; i <= 5; i++)
{Serial.print(i);
Serial.println(": ");
if(*list[i]=="item3")
{Serial.println("diferent"); //
}
Serial.println(*list[i]);
Serial.print("Capacity: ");
Serial.println(list.getSize());
}
}
void loop() {
}