title: How to split LPWSTR with multiple delimiters & return array of LPWSTR in c++?
body: <p>I need to split LPWSTR with multiple delimiters &amp; return array of LPWSTR in c++. How to do it?
  I tried to do from the following question: 
  <a href="https://stackoverflow.com/questions/31883316/how-to-split-char-pointer-with-multiple-delimiters-return-array-of-char-pointe">How to split char pointer with multiple delimiters &amp; return array of char pointers in c++?</a></p>
  
  <p>But it prints ?? for each wstring. What's wrong with it?</p>
  
  <p>can I do it as I tried follow? If so what's the mistake I made? If not how to do it?</p>
  
  <pre><code>std::vector&lt;wstring&gt; splitManyW(const wstring &amp;original, const wstring &amp;delimiters)
  {
      std::wstringstream stream(original);
      std::wstring line;
      vector &lt;wstring&gt; wordVector;
  
      while (std::getline(stream, line)) 
      {
          std::size_t prev = 0, pos;
          while ((pos = line.find_first_of(delimiters, prev)) != std::wstring::npos)
          {
              if (pos &gt; prev)
              {
                  wstring toPush = line.substr(prev, pos-prev);
                  //wstring toPushW = toWide(toPush);
                  wordVector.push_back(toPush);
              }
              prev = pos + 1;
          }
          if (prev &lt; line.length())
          {
              wstring toPush = line.substr(prev, std::wstring::npos);
              //wstring toPushW = toWide(toPush);
              wordVector.push_back(toPush);
          }
      }
      for (int i = 0; i&lt; wordVector.size(); i++)
      {
          //cout &lt;&lt; wordVector[i] &lt;&lt; endl;
          wprintf(L"Event message string: %s\n", wordVector[i]);
      }
      return wordVector;
  }
  
  int main()
  {
      wstring original = L"This:is\nmy:tst?why I hate";
      wstring separators = L":? \n";
  
      vector&lt;wstring&gt; results = splitManyW(original, separators);
  
      getchar();
  }
  </code></pre>