title: Different results using sprintf_s and sprintf for floats using mingw-w64 g++
body: <p>Can anyone explain the different number of chars returned for the exponent between sprintf_s and sprintf family?</p>
  <p>I'm using an Eclipse environment with mingw-w64 and mys64. The version returned is
  g++ (Rev5, Built by MSYS2 project) 10.3.0. I have tried a number of C++ dialects.</p>
  <p>n.b.  The results are consistent in a Visual Studio 2019 Community console app.</p>
  <p>source:</p>
  <pre><code>#include &lt;cstdio&gt;
  
  int main() {
    float fv;
    char szWkg1[20];
    char szWkg2[20];
  
    fv = 0.005f;
    sprintf_s(szWkg1, sizeof(szWkg1), &quot;%6.2E&quot;, fv);
    sprintf(szWkg2, &quot;%6.2E&quot;, fv);
    printf(&quot;sprintf_s &lt;%s&gt; sprintf &lt;%s&gt; printf &lt;%6.2E&gt;&quot;, szWkg1, szWkg2, fv);
    fprintf(stdout, &quot;  fprintf &lt;%6.2E&gt;\n&quot;, fv);
  
    fv = 1000.0f;
    sprintf_s(szWkg1, sizeof(szWkg1), &quot;%6.2E&quot;, fv);
    sprintf(szWkg2, &quot;%6.2E&quot;, fv);
    printf(&quot;sprintf_s &lt;%s&gt; sprintf &lt;%s&gt; printf &lt;%6.2E&gt;&quot;, szWkg1, szWkg2, fv);
    fprintf(stdout, &quot;  fprintf &lt;%6.2E&gt;\n&quot;, fv);
    return 0;
  }
  
  Output:
  sprintf_s &lt;5.00E-003&gt; sprintf &lt;5.00E-03&gt; printf &lt;5.00E-03&gt;  fprintf &lt;5.00E-03&gt;
  sprintf_s &lt;1.00E+003&gt; sprintf &lt;1.00E+03&gt; printf &lt;1.00E+03&gt;  fprintf &lt;1.00E+03&gt;
  </code></pre>