char_traits::length
문자열의 길이를 반환합니다.
static size_t length(
const char_type* _Str
);
매개 변수
- _Str
-문자열 길이가 측정 됩니다 C.
반환 값
않은 null 종결자 포함 하 여 측정 되는 시퀀스의 요소 수입니다.
예제
// char_traits_length.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
int main( )
{
using namespace std;
const char* str1= "Hello";
cout << "The C-string str1 is: " << str1 << endl;
size_t lenStr1;
lenStr1 = char_traits<char>::length ( str1 );
cout << "The length of C-string str1 is: "
<< lenStr1 << "." << endl;
}
요구 사항
헤더: <string>
네임 스페이스: std