Archived

This topic is now archived and is closed to further replies.

random-decay

endless loop...

Recommended Posts

I ask my user for a bet, it must be greater than or equal to 2, or less than or equal than their pot. Let's say they enter a character. BAM! Endless loop! How do I fix this? Or they enter some number like 999999999999999999999999999999 Edited by - random-decay on October 14, 2001 2:46:20 AM Edited by - random-decay on October 14, 2001 2:48:51 AM

Share this post


Link to post
Share on other sites
um, you gotta be more specific... what programming language? how are you getting this input? etc...
without knowing, all i can say is check the input before proceeding, and if it is not correct ask again.

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
How is bet declared? How is it being read? If bet is a char then it may always fall outside your range and thus loop indefinitely. I suggest you run your program through the debugger (if you don't know how to use the debugger, this is a good time to learn!)

You also have the interesting logic bug of doing a logical OR rather than an AND in your condition statement.

Edit: if your user enters a character, it may convert to its ASCII equivalent in integer context (ah, Perl...)


Edited by - Oluseyi on October 14, 2001 4:04:24 AM

Share this post


Link to post
Share on other sites