get length of `wchar_t*` in c++

Jacob picture Jacob · May 18, 2010 · Viewed 79.4k times · Source

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

Answer

Bertrand Marron picture Bertrand Marron · May 18, 2010

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);