Hello all,
two questions:
1. I have some vector<unsigned char> containing binary data. I would like to combine them into one std::string. How is the correct way to accomplish this?
This is my best guess for sample code:
will this code work with binary data, or will it null terminate?Code:vector<unsigned char> data; //conatins some data vector<unsigned char> data2; //contains more data string temp(data.begin(), data.end()); temp.append(data2.begin(), data2.end());
2. A similiar problem.. I have some unsigned char* variables, and I want to combine them into one std::string. How can I accomplish this?
will the member append() work here? or will it null terminate?
something like:
will the above sample code work without null termination?Code:unsigned char* data; //conatins some data unsigned char* data2; //contains more data string temp(reinterpret_cast<const char*>(data)); temp.append(string(reinterpret_cast<const char*>(data2)));
Regards,
Ellay K.




Reply With Quote