Thread: charater testing for password verification

  1. #1

    Exclamation charater testing for password verification

    just wanted to know if someone could point me in the right direction on a problem I'm trying to solve.
    here it is:
    Need to bulid software that reqires user password to meet following criteria.
    1.Password should be atleast 6 chars long
    2.Password should contain at least one uppercase and one lowercase letter
    3.The password should contain one digit,

    Now can the whole string be tested using a for loop and if-statements or does each character need to be tested induvidually.

  2. #2
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    #1. Use the strlen() function in string.h to check lengths of strings for comparisons.

    #2. Use the isupper() and islower() in ctype.h (or cctype for ANSI) to find if characters are uppercase or lower case.

    #3. Use the isdigit() in ctype.h (or cctype for ANSI) to find if a character is a digit.

    You will have to parse the password string character by character like this:

    while( *string != '\0')
       if( isupper(*string) )
          // Do whatever
       if( isdigit(*string) )
          // Do whatever
       string++  // Point to next character
    Good luck...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: Depth Testing, Matrixes, ect.?
    By Zeusbwr in forum Game Programming
    Replies: 8
    Last Post: 12-08-2004, 09:37 AM
  2. C++ bit testing
    By Vicious in forum C++ Programming
    Replies: 3
    Last Post: 09-19-2004, 11:44 AM
  3. tips for testing conditions
    By Silvercord in forum Game Programming
    Replies: 12
    Last Post: 04-10-2003, 01:42 PM
  4. program for Radiation Testing
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 02-07-2002, 01:47 AM
  5. Testing Testing 123.. Oh yeah and...
    By minime6696 in forum Windows Programming
    Replies: 0
    Last Post: 08-13-2001, 09:07 AM