Display the size of a string - C++ STL

C++ examples for STL:string

Description

Display the size of a string

Demo Code

#include <iostream>
#include <string>
using namespace std;
int main()/*  w w  w  .  j a v a2 s  .  com*/
{
   string str1("Alpha");
   string str2("Beta");
   string str3("Gamma");
   string str4;
   cout << "str1 contains " << str1.size() << " characters.\n";
   return 0;
}

Result


Related Tutorials