View Single Post
Join Date: Jul 2005
Posts: 47
Reputation: karen_CSE is an unknown quantity at this point 
Solved Threads: 0
karen_CSE karen_CSE is offline Offline
Light Poster

Re: airplane seating prices

 
0
  #6
Jul 26th, 2005
Originally Posted by Stoned_coder
something like....
  1. #include <iostream>
  2. #include <limits>
  3. using namespace std;
  4.  
  5. int GetInput(string s)
  6. {
  7. cout<<s;
  8. int input;
  9. while (!(cin>>input))
  10. {
  11. cerr<<endl<<"error! re-enter"<<endl;
  12. cin.clear();
  13. cin.ignore(numeric_limits<streamsize>::max(),'\n');
  14. }
  15. return input;
  16. }
  17.  
  18. int main()
  19. {
  20. int windowseatprice = GetInput(string("How much for a window seat"));
  21. return 0;
  22. }
Ummm...hi....I forgot to mention that I'm a level-1 C++ beginner.
your code looks really complicated to me. I didn't learn about #include <limits> yet, nor cerr, nor...this "cin.ignore(numeric_limits<streamsize>::max(),'\n');"

do you know a less-advanced way of doing this?

sorry,
karen
Reply With Quote