pacemaker_yousuf
pacemaker_yousuf

Reputation: 1

How can I get input as an empty string?

#include <bits/stdc++.h>    
using namespace std;

int main()
{
    string s;
    getline(cin, s);
    cout << s << endl;
    return 0;
}

I think it will help someone with my question and answer.

Upvotes: 0

Views: 60

Answers (1)

Matta
Matta

Reputation: 43

In the code you showed, I think pressing only the Enter key will return an empty string.

Upvotes: 2

Related Questions