名前空間
変種
操作

std::wcslen

From cppreference.com
< cpp‎ | string‎ | wide
 
 
 
 
ヘッダ <cwchar> で定義
std::size_t wcslen( const wchar_t* str );

終端ヌルワイド文字の前に来る、ヌルでないワイド文字の数を表す、ワイド文字列の長さを返します。

str が指すワイド文字配列にヌル文字が存在しない場合、動作は未定義です。

目次

[編集] パラメータ

str - 検査対象のヌル終端ワイド文字列へのポインタ

[編集] 戻り値

ヌル終端ワイド文字列 str の長さ。

[編集] 実装例

std::size_t wcslen(const wchar_t* start)
{
    // NB: start is not checked for nullptr!
    const wchar_t* end = start;
    while (*end != L'\0')
        ++end;
    return end - start;
}

[編集]

#include <iostream>
#include <cwchar>
int main()
{
    const wchar_t* str = L"Hello, world!";
    std::wcout << "The length of L\"" << str << "\" is " << std::wcslen(str) << '\n';
}

出力

The length of L"Hello, world!" is 13

[編集] 関連項目

与えられた文字列の長さを返す
(関数) [編集]
次のマルチバイト文字のバイト数を返す
(関数) [編集]
English 日本語 中文(简体) 中文(繁體)