C++ examples for STL:string
A string can consist of zero, one, or more characters.
#include <iostream> #include <string> using namespace std; int main()/* w w w . j a va2 s .c o m*/ { int value; string message; cout << "Enter a number: "; cin >> value; cout << "The number entered is:\n" << value << endl; cout << "Enter text:\n"; getline(cin, message); cout << "The text entered is:\n" << message << endl; cout << int(message.length()); return 0; }