getline
Completed
Read a full name (with spaces) using getline and print Hello, NAME! and the number of characters.
Input
One line.
Output
Two lines.
Example
Input
Ada Lovelace
Output
Hello, Ada Lovelace! 12
Editor
C++
Hints
cin >> name stops at the first space; getline reads the whole line.
Solution explanation
Use getline whenever the input may contain spaces.
Show solution
#include <iostream>
#include <string>
using namespace std;
int main() {
string name;
getline(cin, name);
cout << "Hello, " << name << "!\n" << name.size() << "\n";
return 0;
}