getline
is used to read an entire line of text from an input stream, which is useful for processing input that contains spaces.
Basic Usage:
std::string input;
std::getline(std::cin, input);
With Custom Delimiter:
std::string input;
std::getline(std::cin, input, ','); // Reads until a comma is encountered
For Loop Input:
string s;
int t;cin>>t;
cin.ignore(); // to ignore the '\\n' from the first line after taking the input t;
while(t--){
std::getline(std::cin, input);
}