Borland Tubro C++ 4.5, maybe I don't have a setting turned on or something.
Borland Tubro C++ 4.5, maybe I don't have a setting turned on or something.
It might be possible you have an old compiler, if so your program
cannot compile without few changes on other newer compilers.
But after changing some things it worked fine.
You should check the if the user input is a number. I typed quit (dunno why I just felt like it) and the program went into an infinite loop telling me choose another number.
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
Another good alternative i like to do is writing my own CIN,Originally posted by -=SoKrA=-
You should check the if the user input is a number. I typed quit (dunno why I just felt like it) and the program went into an infinite loop telling me choose another number.
It really isn't that hard. Sokra how about saying how to filter
out numbers? (i don't use console apps, so i dont know too much
about them).
http://cboard.cprogramming.com/showt...threadid=31654Originally posted by Travis Dane
Sokra how about saying how to filter
out numbers? (i don't use console apps, so i dont know too much
about them).
this is a thread about this but if you want more specific...
Ok, here's some code to check the input of numbers:
You can use this code as a guideline. You can assing input's value to an int var and use it without any problems.Code:#include <iostream> #include <cctype> using namespace std; int main() { char input; cout<<"Please input a number (or q to quit): "; cin>>input; if(input == 'q') return 0; else if(isdigit(input)) cout<<"Thankyou for typing the number "<<input<<endl; else cout<<"I said a number or q. Go back to school!"<<endl; return 0; }
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.