As long as I use the char and not some wchar_t type to declare a string will strlen() correctly report the number of chars in the string or are there some very specific cases I need to be aware of? Here is an example:
char *something = "Report all my chars, please!";
strlen(something);
What
strlendoes is basically count all bytes until it hits a zero-byte, the so-called null-terminator, character'\0'.So as long as the string contains a terminator within the bounds of the memory allocated for the string,
strlenwill correctly return the number ofcharin the string.Note that
strlencan't count the number of characters (code points) in a multi-byte encoded string (like UTF-8). It will correctly return the number of bytes in the string though.