get length of `wchar_t*` in c++

巧了我就是萌 提交于 2019-12-03 09:27:53
sizeof (wchar_t);

Edit:

I just noticed the string tag. If you want to know the size of a wchar_t string (wchar_t *), you want to use wcslen(3):

size_t wcslen (const wchar_t *ws);

Assuming that you want to get the length of null terminated C style string, you have two options:

  1. #include <cwchar> and use std::wcslen (dimObjPrefix);,
  2. or #include <string> and use std::char_traits<wchar_t>::length (dimObjPrefix);.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!