| | |
Password Creator Checker
![]() |
•
•
Join Date: Apr 2009
Posts: 22
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Apr 2009
Posts: 22
Reputation:
Solved Threads: 0
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.
that's what i have for now, im trying to add the if function with strlen in it
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.
C Syntax (Toggle Plain Text)
#include <stdio.h> #include <string.h> int main (void) { int length; char pass[8]; printf("Enter a password with 8 characters."); printf("It must have at least 1 digit and 1 alphabet."); 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.
Use the length() function and return a boolean
string str ("pasword");
if str.length() < 7 {
return 0;
}
else{
return 1:
}
string str ("pasword");
if str.length() < 7 {
return 0;
}
else{
return 1:
}
Last edited by extofer; May 5th, 2009 at 6:07 pm.
Gabriel Villa
software development/ IT support consultant
software development/ IT support consultant
C Syntax (Toggle Plain Text)
#include<stdio.h> #include<string.h> int main() { char un[7],pwd[10]; int i,f; printf("\nEnter user name and pwd"); scanf("%s%s",un,pwd); if(strlen(un)==7) { for(i=0;i<strlen(pwd);i++) { if(!isalnum(pwd[i])) f=1; } } if(f==1) printf("pwd error"); else -------proceed--------------- }
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
![]() |
Similar Threads
- Share: Best 101 Free Computer Software For Your Daily Use (Network Security)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- winfix help please! (Viruses, Spyware and other Nasties)
- every program on my computer keeps generating errors (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: Change char to int and store in an array
- Next Thread: Semaphores please
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






