#include using string = std::string; void ignoreTillLineEnd(); string promptfs(string); int main() { string name {promptfs("Enter your name:")}; std::cout << "Hello " << name << "\n"; return 0; } void ignoreTillLineEnd() { std::cin.ignore(std::numeric_limits::max(), '\n'); } string promptfs(string msg) { bool once {false}; string toret {}; do { if (once) { std::cin.clear(); std::cout << "Input Failure!\n"; } std::cout << msg << "\n"; std::cin >> toret; ignoreTillLineEnd(); once = true; } while (std::cin.fail()); return toret; }