xxxxxxxxxx
#include <bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int t;
string a,b;
cin>>a;
cin.ignore(); /*must include this otherwise the cin will
have null space availabe in buffer and getline wont take
anything as input so we must clear or ignore the space
availabe in buffer due to previous input */
getline(cin,b);
cout<<a<<b;
}
xxxxxxxxxx
Make sure you didn't use cin >> str. before calling the function. If you use cin >> str and then want to use getline(cin, str), you must call cin.ignore() before.
string str;
cin >> str;
cin.ignore(); // ignores \n that cin >> str has lefted (if user pressed enter key)
getline(cin, str);