title: std::wcstok in VS 2015
body: <p>I have this toned down used case of code which when compiled with VS 2015 C++ compiler produces a warning. </p>
  
  <pre><code>#include &lt;cwchar&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      wchar_t input[100] = L"A bird came down the walk";
      wchar_t* token = std::wcstok(input, L" ");
      while (token) {
          std::wcout &lt;&lt; token &lt;&lt; '\n';
          token = std::wcstok(nullptr, L" ");
      }
  }
  </code></pre>
  
  <p>This produced following warnings.</p>
  
  <pre><code>warning C4996: 'wcstok': wcstok has been changed to conform with the ISO C standard, adding an extra context parameter. To use the legacy Microsoft wcstok, define _CRT_NON_CONFORMING_WCSTOK.
  1&gt;  c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\corecrt_wstring.h(254): note: see declaration of 'wcstok'
  
  warning C4996: 'wcstok': wcstok has been changed to conform with the ISO C standard, adding an extra context parameter. To use the legacy Microsoft wcstok, define _CRT_NON_CONFORMING_WCSTOK.
  1&gt;  c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\corecrt_wstring.h(254): note: see declaration of 'wcstok'
  </code></pre>
  
  <p>Looking up online, I read about <a href="http://en.cppreference.com/w/cpp/string/wide/wcstok" rel="noreferrer">std::wcstok</a> and <a href="https://msdn.microsoft.com/en-us/library/bb531344.aspx" rel="noreferrer">breaking changes in VS 2015</a> which mentions that C standard has introduced a third parameter and that</p>
  
  <blockquote>
    <p>It used an internal, per-thread context to track state across calls,
    as is done for strtok. The function now has the signature 
    <code>wchar_t* wcstok(wchar_t*, wchar_t const*, wchar_t**)</code>, and requires the caller
    to pass the context as a third argument to the function.</p>
  </blockquote>
  
  <p>At the cost of sounding inherently stupid, I will still go ahead and ask, 
  Can anybody please explain the purpose of this third parameter in simple terms and how it has changed <code>std::wcstok</code> from its earlier version?</p>