【Win32 API】 lstrlenA()
作用
获取指定字符串的长度(不包括终止 null 字符)
函数
int lstrlenA(LPCSTR lpString);
参数
lpString
类型:LPCTSTR
以 null 结尾的字符串。
返回值
类型:int
返回字符串的长度。
支持
最低支持系统版本 | Windows 2000 Professional |
最低支持服务器版本 | Windows 2000 Server |
头文件 | winbase.h (包括 Windows.h) |
库 | Kernel32.lib |
dll | Kernel32.dll |
例子
#include "windows.h"int _tmain(int argc, _TCHAR* argv[])
{char ch1[48] = "ABC123";char ch2[48] = "ABC";int len1 = lstrlenA(ch1);int len2 = lstrlenA(ch2);printf("长度1:%d\n",len1);printf("长度2:%d\n",len2);system("pause");return 0;
}