I have a situation where I read data from a struct and keep appending it to a string so that it can be sent over a socket. When the data is fairly large, this operation is taking a lot of time. Can someone suggest any alternatives?
I have a structure
struct fileInfo
{
int file_id;
char filename[16];
double tag;
}
I do a std::stringstream >>file_id and stringstream.str()
this is repeated for each value, appended to a string and sent
std::ostringstreamfrom<sstream>is designed for exactly that mode of operation.