Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.

Example

// 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.

Requirements

Header: <string>

Namespace: std

Show: