Namespaces
Variants
Views
Actions

Talk:cpp/io/c/fwprintf

From cppreference.com
< Talk:cpp‎ | io

The size parameter is described as:

  up to size - 1 characters may be written, plus the null terminator

This implies no extra consideration is needed for the null character, yet the example is this:

  std::swprintf(warr, sizeof warr - 1, L"Converted from UTF-8: '%s'", narrow_str);

Strongly implying that size does not account for the null terminator. Which is it? Can we please fix the docs or the example.

Yes, the example was quite wrong (it also didn't divide sizeof by sizeof(wchar_t). Thank you for spotting! --Cubbi (talk) 19:02, 21 August 2014 (PDT)