getline is used to read an entire line of text from an input stream, which is useful for processing input that contains spaces.

Usage:

  1. Basic Usage:

    std::string input;
    std::getline(std::cin, input);
    
    
  2. With Custom Delimiter:

    std::string input;
    std::getline(std::cin, input, ','); // Reads until a comma is encountered
    
    
  3. 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); 
    }