Check out example codes for "cin.getline". It will help you in understanding the concepts better.

Code Example 1

cin>>n;
cin.ignore();
cin.getline(cin,string,'\n');

Code Example 2

//getline definition
istream& getline (istream& is, string& str, char delim);

Code Example 3

// extract to string
#include <iostream>
#include <string>

int main ()
{
  std::string name;

  std::cout << "Please, enter your full name: ";
  std::getline (std::cin,name);
  std::cout << "Hello, " << name << "!\n";

  return 0;
}

Code Example 4

// C++ program to demonstrate getline() function 
  
#include <iostream> 
#include <string> 
using namespace std; 
  
int main() 
{ 
    string str; 
  
    cout << "Please enter your name: \n"; 
    getline(cin, str); 
    cout << "Hello, " << str 
         << " welcome to GfG !\n"; 
  
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com