Hello
I have am having trouble setting up a string in a struct - which is then used in two places - in the particle publish and printing on an oled screen. In both places, the string comes out jumbled and I am not sure why.
In the struct, I have tried all these ( separately ):
struct myData {
myData() {
name = NAN;
};
char name[25]; // option 1
std::string name; // option 2
String name; //option 3
};
Then I am referencing it in snprintf like this ( for the publish):
snprintf(data, sizeof(data), "{\"item_name\":\"%s\"}",name);
I am also attempting to print it on my oled screen like this:
char buf[64]; // ( outside my loop)
//inside my loop
snprintf(buf, sizeof(buf), "%s ", name);
oled.print("Item Name "); oled.println(buf);
The error seems to be related to how I am setting up the struct. Could use another pair of eyes. Thxx.