sizeof strlen

摘自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:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值