char 转 string、vector 与 string互转

char 转 string

char c;
string str;
stringstream stream;
stream << c;
str = stream.str();


string 转 vector

vector  vcBuf;
string        stBuf("Hello DaMao!!!");
----------------------------------------------
vcBuf.resize(stBuf.size());
vcBuf.assign(stBuf.begin(), stBuf.end());


vector 转 string 

stBuf.clear();
stBuf.assign(vcBuf.begin(), vcBuf.end());

你可能感兴趣的:(C++)