Code:
#include <stdio.h>#include <string.h>
#include <ctype.h>
int main()
{
char password[20];
int length_check(char[]);
int no_symbols(char[]);
int at_least_two_digit(char[]);
int a,b,c,r;
do
{
printf("Enter your test password: ");
scanf("%s",password);
a = length_check(password);
b = no_symbols(password);
c = at_least_two_digit(password);
r=a+b+c;
if(a==0)
printf("Must have more than eight characters.\n");
if(b==0)
printf("Must consist of only alphabetic characters and digits\n");
if(c==0)
printf("Must consist of at least two numbers 0-9.\n");
}
while(r!=3);
printf("Invalid password!\n");
else
printf("Valid Password!\n");
return 0;
}
int length_check(char p[])
{
int pass;
pass = strlen(p);
if(pass<8);
return 1;
else
return 0;
}
int no_symbols(char p[])
{
int i=0;
int w=0;
while (p[i] != '\0')
{
if(ispunct(p[i]) !=0)
w++;
i++;
}
if (w==0)
return 1;
else
return 0;
}
int at_least_one_digit(char p[])
{
int i=0;
int w=0;
while (p[i] != '\0')
{
if(isdigit(p[i])!=0)
w++;
i++;
}
if(w>=2)
return 1;
else
return 0;
}
Compiling on a mac.
31:1: error: expected expression
else
^
password.c:44:13: warning: if statement has empty body [-Wempty-body]
if(pass<8);
^
password.c:44:13: note: put the semicolon on a separate line to silence this
warning
password.c:46:3: error: expected expression
else
Any help is appreciated.