You can save stringstream data into a struct member using the << operator, just like you would with a regular stringstream. Here's an example:
struct MyStruct {
std::stringstream data;
};
MyStruct myStruct;
myStruct.data << "Hello, world!\n";
Serial.println(myStruct.data.str().c_str());
In this example, we define a struct called MyStruct that has a data member that is a stringstream. We then create an instance of this struct called myStruct.
We then use the << operator to insert the string "Hello, world!\n" into the data member of myStruct. Note that we're using the c_str() function to convert the stringstream to a const char* that we can pass to Serial.println().
Finally, we call Serial.println() to print the contents of the data member of myStruct.
Asked: 2022-06-10 11:00:00 +0000
Seen: 7 times
Last updated: May 03 '21