Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

putting passwords into C programs!

  • 11-02-2002 04: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, Registered Users 2 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, Registered Users 2 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