Originally Posted by
rosemary
ok. i changed it a bunch, but still need help. be patient with me. thanks.
Let's tidy up the code a bit so it's easier to read.
Code:
main () // should be "int main(void)"
{
char ch1;
char ch2;
int pass;
printf("Please Enter Your Password>\n");
pass = 0; // can be initialized above at the declaration
scanf("%c%c", &ch1, &ch2);
while(pass) // "pass" is zero, so this won't execute - a "do-while" loop would be better here
{
if(ch1 == 'c' && ch2 == 's')
{
printf("Access Granted.\n");
break; // this works, but so would setting "pass" equal to 1
}
else
printf("Access Denied.\n");
scanf("%c%c", &ch1, &ch2); // You want this as part of the "else" statement. If so,
// enclose these lines in brackets like you did in the "if()"
}
// don't forget to "return 0;"!
}