C++ Program to Demonstrate the use of String Class
#include<iostream>
#include<string>
using namespace std;
int main()
{
std::string s;
cout << "Enter your first name : ";
cin >> s;
cout << "The length of your name is " << s.length() << endl;
cout << "Nice to meet you ";
/* Printing using const_iterator */
for (std::string::const_iterator i = s.begin(); i != s.end(); i++)
cout << *i;
cout << "!" << endl;
}
Output:
Enter your first name : George
The length of your name is 6
Nice to meet you George!
