I want to set a checker using "While Loop" on line 34 to filter out non-integer input. The problem i am having on the checker is that it repeatedly printing itself bases on how many non-integer letter or symbol I had entered before returned to line 33. I kind of get a sense that C++ reads my input number-by-number and the message bar comes out whenever it reads something non-integer rather than integer number as a whole. For instance, "1" "a" "b" rather than "1ab". In this case, the first number passed the checker and moved on but the rest got capture with two warning messages follow suit. How can I ask C++ to read the number as a whole? Many Thanks for this.
Other problems that you need to fix:
• You need to add return statements to printheader and CheckInputValu, or change the return type to void.
• You need to initialize a before passing it as argument to CheckInputValu.
• In CheckInputValu you have two variables named y, which is confusing. The loop always runs three times no matter how big the array is so you might not use all elements, ore you might run out of bounds.
I think i kind of get a sense of where the problem is originated. Its all about "!int" in which C++ doesn't read the number as a string. I am using stringstream to convert Int to string and sort of scan the string input if it contains letter or symobl or whilespace. It works quite the way i want it to do.
I further tweaked my code like this after including a string function. But one thing kept bugging me on line 27 and line 29. I knew npos means found or not found from a string input. But why include two seems so contradictory statements? What does it do to the one within the if-statement?
line 27: theInput.find_first_not_of("0123456789")!=std::string::npos
line 29: theInput.find_first_not_of("0123456789")==std::string::npos