http://en.cppreference.com/w/cpp/utility/to_chars
Reference does not say anything about that, but the example is (for me) clearly using a null-terminated string, otherwise how could it know where to end, since std::array::data
returns only a pointer.
#include <iostream>
#include <charconv>
#include <array>
int main()
{
std::array<char, 10> str{};
std::to_chars(str.data(), str.data()+str.size(), 42);
std::cout << str.data();
}
Unfortunately I can't test it myself because AFAIK no compiler supports it yet: https://en.cppreference.com/w/cpp/compiler_support
Edit:
Forgot that str
is initialized with zeros, however question is still relevant.