There's a strlen, and a wcslen function, but is there a templated character array length function so you can do something like strlen<char>
or strlen<wchar_t>
?
If not, then I guess I'll write my own.
strlen() in C-style strings can be replaced by C++ std::strings. sizeof() in C is as an argument to functions like malloc(), memcpy() or memset() can be replaced by C++ (use new, std::copy(), and std::fill() or constructors).
The strlen() function in C is used to calculate the length of a string. Note: strlen() calculates the length of a string up to, but not including, the terminating null character. Return Value: The function returns the length of the string passed to it.
The strnlen() function computes the length of the string pointed to by s , not including the terminating null character, up to a maximum of maxlen bytes. The function doesn't check any more than the first maxlen bytes.
You have the char_traits helper used by std::string.
It provides char_traits<char>::length
and char_traits<wchar_t>::length
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With