public static member function
<string>
std::char_traits::lengthstatic size_t length (const char_type* s);
Get length of null-terminated string
Returns the length of the null-terminated character sequence s.The behavior implemented by all character traits types shall be to return the position of the first character for which member eq returns false when compared against charT().
This function is equivalent to strlen (for char) and wcslen (for wchar_t).
size_t is an unsigned integral type.
1
2
3
4
5
6
7
8
9
10
11
12
// char_traits::length
#include <iostream> // std::cout
#include <string> // std::char_traits
int main ()
{
const char * foo = "String literal";
std::cout << "foo has a length of ";
std::cout << std::char_traits<char>::length(foo);
std::cout << " characters.\n";
return 0;
}
foo has a length of 14 characters.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4