I have no idea how to go further with this program that I'm about to create. This is the idea:
Validate the password input to check if the password has at least one uppercase letter, lowercase letter and a number.
Some parts of it is broken at the moment. For instance the false, true statements. And the "undynamic" char array in the main function. I don't know how to make that at the moment either. But it explains what I'm looking for.
So how can I validate this without writing too much code?
This is my current code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int passval(char pw[])
{
int x;
for (x = 0; x < sizeof(pw); x++) {
if ( (isalnum(pw[x])) || (ispunct(pw[x])) ) {
return 0;
} else {
return 1;
}
}
return 0;
}
int main()
{
char password[20];
printf("Enter password: ");
scanf("%s", password);
if (passval(password) == TRUE) {
printf("Password is TRUE");
}
return 0;
}