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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

putting passwords into C programs!

  • 11-02-2002 3: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