最終更新日時:
が更新

履歴 編集

function
<cstring>

std::strlen

namespace std {
  size_t strlen(const char* s);
}

概要

文字列の長さを取得する。

効果

sが指す文字列の長さを求める。

戻り値

sが指す文字列の、終端のヌル文字より前にある文字の個数を返す。

備考

  • この関数は、フリースタンディング処理系でも使用できる。

#include <cstring>
#include <iostream>

int main()
{
  std::cout << std::strlen("hello") << std::endl;
}

出力

5

バージョン

言語

  • C++98

関連項目

参照