std::wcslen
From cppreference.com
| ヘッダ <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
[編集] 関連項目
| 与えられた文字列の長さを返す (関数) | |
| 次のマルチバイト文字のバイト数を返す (関数) | |
| C のドキュメント (wcslen)
| |