- cstring[meta header]
- std[meta namespace]
- function[meta id-type]
namespace std {
size_t strlen(const char* s);
}- size_t[link /reference/cstddef/size_t.md]
文字列の長さを取得する。
sが指す文字列の長さを求める。
sが指す文字列の、終端のヌル文字より前にある文字の個数を返す。
- この関数は、フリースタンディング処理系でも使用できる。
#include <cstring>
#include <iostream>
int main()
{
std::cout << std::strlen("hello") << std::endl;
}- std::strlen[color ff0000]
5
- C++98
std::char_traits::length: 文字列の長さを取得する(文字特性版)
- P2338R4 Freestanding Library: Character primitives and the C library
- C++26で、この関数がフリースタンディング処理系で使用可能になった