Thread: Validation of password please help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2019
    Posts
    5

    Exclamation Validation of password please help

    program should validate the input data (password) based on the following rules: The password length should have a minimum length of 6 and maximum of 15 characters Some characters aren’t allowed in the password including “space” and “-”. If user includesthese two characters in the input, the program should display “invalid password”.
    Code:
    int main()
    {
      char password[15];
      int lenght;
    
      int str;
      printf("Please enter the password:\n");
      printf("note:no space or - in password\n");
      printf("note:min password lenght =6 and max password lenght =15\n");
      fgets(password, 15, stdin);
      int i = strlen(password);
    
      if (i < 5 || i > 14) {
        printf("please check the lenght rules ");
    
      }
    
      else if (i > 0) {
        for (int j = 0; j <= i; j++) {
          password[j] == ' ';
          password[j] == '-';
    
        }
        printf("No space is allowed or any hypens - ,please try again");
      } else
    
        printf("registered");
    
    }
    Last edited by Salem; 06-30-2019 at 12:25 PM. Reason: Remove crayola

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-29-2014, 02:08 AM
  2. Validation
    By ulti-killer in forum C Programming
    Replies: 8
    Last Post: 11-15-2012, 12:06 AM
  3. validation
    By yjn in forum C Programming
    Replies: 1
    Last Post: 03-16-2012, 08:37 AM
  4. Replies: 2
    Last Post: 01-07-2009, 10:35 AM
  5. validation
    By Ideswa in forum C++ Programming
    Replies: 11
    Last Post: 01-30-2006, 01:01 PM

Tags for this Thread