Hi all!
I've been searching the internet and various C++ books for quite some time now, and I appear to have reached a brick wall.
As suggested in a given algorithm written by my professor, during input validation, if the stream goes into failure, I am to "reset cin" followed by "clear cin.."
Even though I'm still learning the ins and outs of C++, I have found this way of doing it:
cin.clear();
cin.ignore(250, '/n')
Now, this would be fine and dandy, however that does not exactly match the given algorithm (as mentioned above).
After spending way too much time trying to find a reset function, I came across" cin.reset();
on one lone website.
Upon trying to implement my hopeful find, I my complier spits out "‘struct std::istream’ has no member named ‘reset’" which, if I'm not mistaken, refers to a missing header file.
And, yes, I have tried numerous header files.
Aside from CIN reset, which appears to be a totally different bowl of cheerios, I can only find a tiny handful of cin.reset();
mentioned elsewhere on the internet. Even my C++ textbooks, and "C++ in a Nutshell" make no mention of cin.reset();
Can anyone shed some insight on cin.reset()
? Does it really exist?
If so, what header file do I need to include?
Am I worrying about the exact wording of my prof's algorithm too much and just use
cin.clear();
cin.ignore(250, '/n')
?
I'd really appreciate any insight I can get on this.
Thanks in advance and have a wonderful Saturday!