Q:

How can I stop cin >> with just enter without typing words in C++? 

Why does cin keep prompting even if I hit enter? 
#include <iostream>
using namespace std;

int main(){
    string name = "";
    cout << "What's your name?"; 
    cin  >> name;

    cout << "Hello "";
    if (name == "")
       cout << "World!"; 
    else
       cout << name + "!"; 
    return 0;
}

I want cin >> to stop when I hit enter without typing any words so if the user enters nothing it will show a default Hollow World message and otherwise customized message.  

A:

cin >> name;keeps reading until you've entered something.  You want a function that just reads a single line.  That function is called getline. 
#include <iostream>
#include <string>
using namespace std;

int main(){
    string name = "";
    cout << "What's your name?"; 
    getline(cin, name);

    cout << "Hello "";
    if (name == ""){
       cout << "World!"; 
    else
       cout << name + "!"; 
    return 0;
}

