In this C++ code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string S;
getline(cin,S);
cout<<S;
return 0;
}
It prints the string with spaces, eg:
Input:
abc def
Output:
abc def
However, in this code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string S;
getline(cin,S);
cout<<S;
return 0;
}
It does not print any output, eg:
Input:
1
abc def
Output:
How is that even possible? Please help. Where am I going wrong?