How would you convert a std::string_view
to a null-terminated c string? I've passed a string_view
into a function, and need to pass that into another function, which takes a const char*
parameter. However, looking at this documentation for string_view
, it says
data()
may return a pointer to a buffer that is not null-terminated. Therefore it is typically a mistake to passdata()
to a routine that takes just aconst CharT*
and expects a null-terminated string.
Is there a way to properly get a null-terminated c string from a string_view
?