How to stop a while loop

前端 未结 5 1875
醉梦人生
醉梦人生 2021-01-14 14:41

This while loop never ends. For example, when i enter a wrong password it will keep on going to the \"incorrect password\" part over and over again.

Logo();
         


        
5条回答
  •  佛祖请我去吃肉
    2021-01-14 15:14

    The while loop is infinite because you never allow the user to input a new password or username. When the if statement fails, it will return to loop header (where it will still be wrong) and continue onwards.

    Give the user a chance to enter in a new user/pass combo and then the loop can still be finite (provided the user eventually provides the correct credentials).

提交回复
热议问题