+ 1
Password validator
Can we create password validator in C, which has alphanumeric characters and atleast one special character without space???
2 Answers
+ 2
Why should that not be possible?
+ 2
#include <stdio.h>
main()
{
char s[100];
scanf("%s",&s);
int i,length ,numbers=0, special_characters=0;
length=strlen(s);
for(i=0;i<length;i++){
if(s[i]>='0'&&s[i]<='9'){
numbers++;
}
else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='#x27;||s[i]=='%'||s[i]=='&'||s[i]=='*'){
special_characters++;
}
}
if(length>=7 && special_characters>=1 && numbers>=2){
printf("Strong");
}
else {
printf("Weak");
}
}
You can try this one..It will be valid if at least 1 special character, length>=7 and 2 or more numbers.
You can modify this as you need..
.