challenge 1 (correct me if the code is wrong)

0 kushagra singh · February 12, 2015
#include 
#include
#include
#include
#include

int main()
{
  char password;

  printf("Password: \n");
  scanf(" %c/n", &password);

  if( isupper(password) || isdigit(password) || password=='$'){

        printf("Good to go! \n");
    }
  else{
  printf("Bad password! ;)", password);
  }

return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Lazar Bulic · February 12, 2015
There are many thing to correct here. 

1) Lets start variable for password. 
So user should input a password, so that password is something like this: "Password123". So what type of input is that. Its a string. So what you want to do is make a string type variable.

2) So now that you have a string type variable you need to ask user to input it. Your:

scanf(" %c/n", &password);

won't work, so find a correct solution.  P.S. don't put anything in " " in scanf. You just need variable type ex. %c %d ........

3) In your line 

printf("Bad password! https://www.thenewboston.com/images/emoticons/wink.png", password);

Please check how print works and try it again.

Also With these modifications you will see that your code needs more work that I haven't included but I am sure you will figure it out. 


What your code is doing is checking just the first character that your user inputs :) 
  • 1

C

107,265 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator