Cpp - Read three letter at most

Description

Read three letter at most

Demo

#include <iostream> 
#include <iomanip>       // Manipulator setw() 
#include <string>        // Class string 
using namespace std; 

int main() /*from w w  w  .  ja va2s. co m*/
{ 
    string word;          // To read a word. 
    cout << "Let's go! Press the return key: "; 

    cin.get();            // Input newline character 

    cout << " Enter a word "                            // " 
            "containing three characters at the most: ";// " 

    cin  >> setw(3) >> word; 

    cout << "Your input: "  << word << endl;             

    return 0; 
}

Result

Related Exercise