Instantiated member variants
length
Template: std::char_traits<T>
Specializations:
charwchar_tchar8_tchar16_tchar32_t
Min standard notice:
Returns the length of the character sequence pointed to by s, that is, the position of the terminating null character (char_type()).
# Declarations
static std::size_t length( const char_type* s );
(constexpr since C++17)
# Parameters
s: pointer to a character sequence to return length of
# Return value
The length of character sequence pointed to by s.
# Example
#include <iomanip>
#include <iostream>
#include <string>
void print(const char* str)
{
std::cout << std::quoted(str) << " has length = "
<< std::char_traits<char>::length(str) << '\n';
}
int main()
{
print("foo");
std::string s{"booo"};
print(s.c_str());
}