title: How to store text in wchar_t pointer parameter
body: <p>I want to dll export some functions from cpp to dart and in order to do this I need to create a function with a pointer parameter where I will send text.</p>
  <p>But after many searches I found no solution that works.</p>
  <p>My question is: How to create a function with a <code>wchar_t*</code> parameter, and fill that variable with text? I have no knowledge of cpp pointers, I usually dont code in cpp.</p>
  <p>Here is my code, it gives errors:</p>
  <pre class="lang-cpp prettyprint-override"><code>
  //extern &quot;C&quot; __declspec(dllexport) 
  void getAudioDevices(wchar_t* output, int outSize)
  {
      std::vector&lt;DeviceProps&gt; result = EnumAudioDevices(eRender);
      std::wstring listOutput(L&quot;&quot;);
      if (!result.empty())
      {
          for (const auto&amp; device : result)
          {
              std::wstring info(L&quot;&quot;);
              info += device.name; //PCWSTR
              info += L&quot;\n&quot;;
              info += device.iconInfo; //PCWSTR
              info += L&quot;\n&quot;;
              info += device.id; //LPWSTR
              info += L&quot;\n&quot;;
              info += device.isActive ? L&quot;true&quot; : L&quot;false&quot;;
              info += L&quot;\n[][][][]\n&quot;;
              listOutput += info.c_str();
          }
      }
      wcscpy_s(output, outSize, listOutput.c_str());
  }
  int wmain(int argc, WCHAR* argv[])
  {
      WCHAR output[1000];
      getAudioDevices(output, sizeof(output));
      cout &lt;&lt; output &lt;&lt; endl;
  
  }
  
  </code></pre>