Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

putting passwords into C programs!

Options
  • 11-02-2002 4:05pm
    #1
    Closed Accounts Posts: 64 ✭✭


    hey
    i'm doing a project for college using C and i need to put a password into it. but i want it to cut out after 3 attempts! i have the code working already but i'm not sure how make it go back to the main menu after the incorrect password has been entered in 3 times! n e suggestions how to do it??!

    thanks
    W_L

    ps i assume i need some sort of for loop for this??


Comments

  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Correct. You need a loop.

    The logic is simple. Here it is in very
    non-C pseudo-code.
    counter = 1
    passwordOK = false
    while not PasswordOK and counter <= 3
    ask for password
    if password ok
    passwordOK = true
    else
    counter = counter + 1
    end if
    end while

    I think thats more than enough help. Anything more than that, and I'm doing your homework. Hopefully an admin wont slap me and tell me that this is already too much help......

    jc


  • Closed Accounts Posts: 64 ✭✭wee_lady


    hehe thank u! it was something like that i was trying to do but i know now where i was going wrong! thanks a million...i appreciate it!


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    I'm guessing you went wrong by using a for loop instead of a while :)

    jc


  • Closed Accounts Posts: 64 ✭✭wee_lady


    yeah u're right! thanks for the help...i got it nearly working now! let's hope the rest of my project goes that way!!


Advertisement