I need a function to get a string input from the user. I don't want to to use cin because I only want return (\r) to mark the end of input. I've done the following:
std::string GetInput()
{
std::string str = "\0";
char ch;
do
{
ch = getch();
if(ch) str += ch;
putch(ch);
}
while (ch!='\r');
return str;
}
It works but I'm not quite satisfied with it as it doesn't fully support Backspace and Right/Left Arrow keyboard buttons. My question is, how can I get input from the user, without the use of cin, while giving the user a cin-like feeling (full keyboard support)?
getline,cinand so on.getlineto do that.