I am reading books to improve my C++ and I wanted to try to get the leftover input from the input buffer after using the delimiter in getline(), this code works, it skips the cin statement and outputs the leftover buffer contents but my question is will it always do this? or is there a better way to do it?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string input;
string leftoverInput;
cout << "Enter some text" << endl;
getline(cin, input, ',');
cin >> leftoverInput;
cout << input << endl;
cout << leftoverInput << endl;
return 0;
}