Using strlen : string function « Data Types « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

#include <cstring>
using std::strlen;                        

int main()
{
   char *string1 = "asdfasdfasdfasdf";
   char *string2 = "     f    ";
   char *string3 = "       ";

   cout << "The length of \"" << string1 << "\" is " << strlen( string1 )
      << "\nThe length of \"" << string2 << "\" is " << strlen( string2 )
      << "\nThe length of \"" << string3 << "\" is " << strlen( string3 ) 
      << endl;
   return 0;
}
The length of "asdfasdfasdfasdf" is 16
The length of "     f    " is 10
The length of "       " is 7








2.24.string function
2.24.1.Using strcpy()
2.24.2.Using strncpy()
2.24.3.strcpy, strlen, strcmp, strcat
2.24.4.Convert a string to uppercase.
2.24.5.Using strcat and strncat.
2.24.6.Using strcmp and strncmp
2.24.7.Using strtok
2.24.8.Using strlen