I want to have cin read input from a string.
Is there a way to have it do this?
Something like this:
const char * s = \"123 ab\"; cin.readFro
In C++17, Ben Voigt's solution won't compile unless you use basic_stringbuf. Instead use the one below:
basic_stringbuf
stringbuf s; const char *userInput = "10 1 2 3 4 5 6 7 8 9 10 3 7"; s.sputn(userInput, strlen(userInput)); cin.rdbuf(&s);