Password Creator Checker

Reply

Join Date: Apr 2009
Posts: 22
Reputation: moiron is an unknown quantity at this point 
Solved Threads: 0
moiron moiron is offline Offline
Newbie Poster

Password Creator Checker

 
0
  #1
May 5th, 2009
i need help making a password program. it lets the use input a password and check it if it is following the password rules, which are the following:

must have exactly 7 characters, only alphabets and digits are allowed.

i don't exactly know how to put that in an if else function, but i know i have to use that.

i also don't know if the string.h library is needed but, in our book, the question was from a chapter with strings.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,602
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: Password Creator Checker

 
0
  #2
May 5th, 2009
use "strlen" and check character ranges. look at your ascii table.

post some code if you want any more advice.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 22
Reputation: moiron is an unknown quantity at this point 
Solved Threads: 0
moiron moiron is offline Offline
Newbie Poster

Re: Password Creator Checker

 
0
  #3
May 5th, 2009
i guess i can use that to check the length, and use the if else to see if the length is exactly 7.
and since the password is supposed to be 7 would i need to make the array size 8 for the \0 part of the string?

since u told me to post a code im gonna try but i know its wrong.
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main (void)
  5. {
  6. int length;
  7. char pass[8];
  8. printf("Enter a password with 8 characters.");
  9. printf("It must have at least 1 digit and 1 alphabet.");
  10.  
  11. fgets( pass, 8, stdin);

that's what i have for now, im trying to add the if function with strlen in it
Last edited by moiron; May 5th, 2009 at 5:38 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 239
Reputation: extofer is an unknown quantity at this point 
Solved Threads: 5
extofer's Avatar
extofer extofer is offline Offline
Posting Whiz in Training

Re: Password Creator Checker

 
-1
  #4
May 5th, 2009
Use the length() function and return a boolean

string str ("pasword");

if str.length() < 7 {
return 0;
}
else{
return 1:
}
Last edited by extofer; May 5th, 2009 at 6:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,602
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: Password Creator Checker

 
0
  #5
May 5th, 2009
that doesnt help him if his password is supposed to be EXACTLY seven characters, now does it?

and this is C, not C++
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Password Creator Checker

 
0
  #6
May 6th, 2009
After reading in the password call functions to test each individual rule. Don't try to test all things in one function, or ghod forbid right after the read.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 19
Reputation: dmachop is an unknown quantity at this point 
Solved Threads: 1
dmachop's Avatar
dmachop dmachop is offline Offline
Newbie Poster

Re: Password Creator Checker

 
0
  #7
May 8th, 2009
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6. char un[7],pwd[10];
  7. int i,f;
  8. printf("\nEnter user name and pwd");
  9. scanf("%s%s",un,pwd);
  10. if(strlen(un)==7)
  11. {
  12. for(i=0;i<strlen(pwd);i++)
  13. {
  14. if(!isalnum(pwd[i]))
  15. f=1;
  16. }
  17. }
  18. if(f==1)
  19. printf("pwd error");
  20. else
  21. -------proceed---------------
  22. }

I think the question is incomplete and need more details...........

SNIP
Last edited by happygeek; May 12th, 2009 at 7:13 am. Reason: fake sig snipped
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC