Possible Duplicate:
Converting std::string to std::vector<char>
I tried:
std::string str = "hello";
std::vector<char> data;
std::copy(str.c_str(), str.c_str()+str.length(), data);
but it does not work=( So I wonder How to copy std::string into std::vector<char> or std::vector<uchar> ?
std::vectorhas a constructor that takes two iterators. You can use that:If you already have a vector and want to add the characters at the end, you need a back inserter: