且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取程序中特定字符串占用的字节数?

更新时间:2022-11-16 12:59:53

strlen 返回纯C字符串的字符串长度。

strlen returns the length of string of a plain C string.


AC字符串与字符串开头和终止空字符之间的字符数量一样长。

A C string is as long as the amount of characters between the beginning of the string and the terminating null character.

如果你使用String对象,你可以使用 length

If you're using the String object you can use the length or size method of the object:

http://www.cplusplus.com/reference/string/string/length/