I have a struct representing ASCII data:
struct LineData
{
char _asciiData[256];
uint8_t _asciiDataLength;
}
created using:
std::string s = "some data here";
memcpy(obj._asciiData, s.length());
obj._asciiDataLength = s.length();
How do I write the char array to file as ASCII, in the lowest latency? I want to avoid the intermediary stage of creating a temporary std::string.
I tried:
file.write((char *)obj._asciiData, sizeof(obj._asciiDataLength));
file << std::endl;
but my file just contains '0' each line.
ostream.writesizeof(obj._asciiDataLength)is wrongchararray is zero terminated you can just useoperator <<to output it doesn't need a string?