(C++) AskUserForString

March 25, 2018 ยท View on GitHub

AskUserForString is a user I/O std::string code snippet to ask the user for a single-line input, which is then converted to std::string.

#include <iostream>
#include <string>

std::string AskUserForString() noexcept
{
  std::string s;
  std::getline(std::cin,s);
  return s;
}