From: "Mark Tsui" Newsgroups: comp.os.msdos.djgpp Subject: Input problem Date: Thu, 29 Oct 1998 21:21:51 +1100 Organization: A customer of Netspace Internet Lines: 71 Message-ID: <719fs7$9tr$1@otis.netspace.net.au> NNTP-Posting-Host: dialup-m2-15.sydney.netspace.net.au X-Trace: otis.netspace.net.au 909656775 10171 210.15.248.79 (29 Oct 1998 10:26:15 GMT) X-Complaints-To: abuse AT netspace DOT net DOT au NNTP-Posting-Date: 29 Oct 1998 10:26:15 GMT X-Newsreader: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com This program is a simple guessing game. You type in numbers and it says whether the number is higher or lower. When I enter numbers, it is works fine. The problem is, when I type in a letter instead of a number the program goes pscho. From what I see on the screen, I think it is just going through my program without asking for further input. Can you help me please? Thanks in advance. // Guessing Game #include #include #include #include main() { int r, guess, tries, playagain; clrscr(); do { r = (random() & 100); cout << "Hello, this is a guessing game enter a number between 0-99:\n"; for(tries=0; ;tries++) { cin >> guess; if(guess > r) cout << "Too big\n"; if(guess < r) cout << "Too small\n"; if(guess == r) { cout << "Yes you guessed right after "<< tries << "tries.\n"; break; } if(tries > 15) { cout << "You are too dumb, you still can't get it after " << tries << " tries.\n"; cout << "The answer is " << r; break; } } cout << "Do you want to play again?\n"; cin >> playagain; } while(playagain); cout << "Bye!"; getch(); return 0; }