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
that cin >> str has lefted (if user pressed enter key)
getline(cin, str);