Hello as the title suggests I want to convert a vector,
std::vector<std::string>
to a c-style string, like
char* buffer.
The reason I want the vector to become a c-style string is because I am currently working with the WinApi, and I am specifically trying to use
SetWindowTextA()
which does not take a vector. And yes, I have to read the data in to a string vector first so there's not really anything I can change there. So if you could help me or point me in the right direction I'd be more than happy
EDIT: To further explain: Yes I will get several string loaded in to the vector. I simply want all those strings to combine in to one string.
Greetings, ye546
So just combine the vector strings into a single string, then call c_str() to convert to a char*.
std::vector<std::string> vec;
...
std::string combined;
for (const auto& s : vec)
combined += s;
WinAPI(combined.c_str());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.