getline() with delimiter

#include <bits/stdc++.h>
using namespace std;

int main()
{
  string str;
  cout << "Enter a string(r to end): ";

  getline(cin, str, 'r');
  cout << "You entered: " << str << endl;
  return 0;
}

Last updated