fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iterator>
  5. using namespace std;
  6.  
  7. std::wstring test(const std::string& str ) {
  8. std::wstring ext;
  9. ext.reserve(str.length()+2);
  10.  
  11. std::transform(str.begin(), str.end(), back_inserter(ext), [](char t)->wchar_t {
  12. return t == ';' ? 0 : t;
  13. });
  14. ext.push_back(0);
  15. ext.push_back(0);
  16.  
  17. return ext;
  18. }
  19.  
  20. int main(int,char*[]) {
  21. std::wstring asdf = test("hello;how;are;you");
  22.  
  23. std::wcout << asdf.length() << L' ' << asdf << std::endl;
  24. std::wcout.write(asdf.c_str(),asdf.length());
  25. }
Success #stdin #stdout 0s 3488KB
stdin
Standard input is empty
stdout
19 hellohowareyou
hellohowareyou