Export (0) Print
Expand All

char_traits::length

Returns the length of a string.

static size_t length( 
   const char_type* _Str 
);

_Str

The C-string whose length is to be measured.

The number of elements in the sequence being measured, not including the null terminator.

// 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;
}
The C-string str1 is: Hello
The length of C-string str1 is: 5.

Header: <string>

Namespace: std

Show:
© 2014 Microsoft