I have std::stringstream
with 1 byte:
std::stringstream message;
message.write((const char[]) {0x55}, 1);
std::string res(message.str());
How append int a = 1;
(4 bytes)?
I want to get as values stored in the message
's underlying std::string
:
0x55 0x00 0x00 0x00 0x01
And right tool I chose for the job with the sequence of bytes?
Simply like that:
As you mention "specific socket protocol", you'll probably need to take care of the network byte order using the
htonl()
function: