Advertisement
Guest User

Problems Detecting a Character

a guest
Dec 28th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     char password[100];
  7.     int i;
  8.  
  9.     printf("Please input a password, it must meet the requirements of \n");
  10.     printf("1. Contain at least one $ character \n");
  11.     printf("2. Contain at least one number \n");
  12.     printf("3. Contain at least one uppercase letter \n");
  13.     printf("4. Contain at least one lower case letter \n");
  14.     scanf ("%c", &password);
  15.  
  16.     for(i=0;i<=100;i++){
  17.         /*Checks all the above values for i for having a corresponding character in the string that is == to $
  18.         Problem: Each time it is run, even with a '$' included in the password, what the if function is testing for never comes out            true
  19.         It will always go to the next if statement that is outside of the for loop*/
  20.         if(password[i]=='$'){
  21.             break;
  22.         }
  23.     }
  24.     if(i=100){
  25.         printf("Your password does not contain a '$'");
  26.     }
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement