wcslen与lstrlen如何区别?怎么使用
------解决方案--------------------
lstrlen应该是strlen吧,在SDK帮助上说的有呀,原文是:
“Each of these functions returns the number of characters in string, not including the terminating null character. wcslen is a wide-character version of strlen; the argument of wcslen is a wide-character string. wcslen and strlen behave identically otherwise. ”
wcslen针对的是宽字符。
两者的参数也有体现的:
size_t strlen( const char *string );
size_t wcslen( const wchar_t *string );
------解决方案--------------------
楼上说lstrlen的可不对哦。
The lstrlen function returns the length in bytes (ANSI version) or WCHAR values (Unicode version) of the specified string (not including the terminating null character).
------解决方案--------------------
The return value of lstrlen() function specifies the length of the string, in TCHARs. This refers to bytes for ANSI versions of the function or WCHARs for Unicode versions.
编译环境依据具体的编码类型来决定TCHAR是ANSI字符集 还是宽字符编码。得到对应的长度。
------解决方案--------------------
补充下:
size_t strlen( const char *string );
size_t wcslen( const wchar_t *string );
int lstrlen(
LPCTSTR lpString // string to count
);
strlen()返回ANSI字符串长度;
wcslen()返回宽字符串长度;
lstrlen()依据字符串具体参数类型返回其长度。
------解决方案--------------------
同意楼上的。所以要用lstrlen(),lstrcpy等api