简体   繁体   中英

get length of `wchar_t*` in c++

Please, how can I find out the length of a variable of type wchar_t* in c++?

code example below:

wchar_t* dimObjPrefix = L"retro_";

I would like to find out how many characters dimObjPrefix contains

如果你想知道wchar_t字符串wchar_t * )的大小,你想使用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); .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM