The question is simple: What is the quickest way of finding the position of the null-terminator ('\0') in a string buffer?
std::array<char, 100> str { "A sample string literal" };
I guess one option is to use the std::strlen
.
Another option that I can think of is std::find
or maybe even std::ranges::find
:
const auto posOfNull { std::find( str.cbegin( ), str.cend( ), '\0' ) };
Now would it make a difference if an ExecutionPolicy
(e.g. std::execution::par
) was passed to it as its first argument? If it would, then which policy is the appropriate one for this particular case?
Or maybe a 3rd option that I don't know about?