摘自MSDN
strlen:
Each of these functions returns the number of characters in str, excluding the terminal NULL. No return value is reserved to indicate an error, except for _mbstrlen, which returns -1 if the string contains an invalid multibyte character.
strlen interprets the string as a single-byte character string, so its return value is always equal to the number of bytes, even if the string contains multibyte characters. wcslen is a wide-character version of strlen; the argument of wcslen is a wide-character string and the count of characters is in wide (two-byte) characters. wcslen and strlen behave identically otherwise.
_mbslen,_mbslen_l, _mbstrlenand_mbstrlen_l return the number of multibyte characters in a multibyte-character string but they do not test for multibyte-character validity. _mbstrlen and_mbstrlen_l tests for multibyte-character validity and recognizes multibyte-character sequencessetlocale, _wsetlocale. If the string passed to _mbstrlen or_mbstrlen_l contain an invalid multibyte character for the code page, it returns -1 and sets errno to EILSEQ.
sizeof:
The result of the sizeof operator is of type size_t, an integral type defined in the include file STDDEF.H. This operator allows you to avoid specifying machine-dependent data sizes in your programs.
The operand to sizeof can be one of the following:
-
A type name. To use sizeof with a type name, the name must be enclosed in parentheses.
-
An expression. When used with an expression, sizeof can be specified with or without the parentheses. The expression is not evaluated.
When the sizeof operator is applied to an object of type char, it yields 1. When the sizeof operator is applied to an array, it yields the total number of bytes in that array, not the size of the pointer represented by the array identifier. To obtain the size of the pointer represented by the array identifier, pass it as a parameter to a function that uses sizeof. For example: