Ok, I was trying to make a password program just to test it out for practice ( I am new to C). however, there are no grammar errors in this code, it just doesn't flow right or something. So if someone could tell me why it doesn't work right o give a sugestion of another way of doing it.. that would be helpful... thanks..
***Also, ignore the part where I print the string length, that was just for testing purposes***
Code:#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i;
int z;
int q;
int ctr = 0;
char password[] = "Password";
char entry[20];
printf("To get into the program, you must enter the correct password.\n");
printf("Type in your password(upper and lower case matter).\n");
gets(entry);
i = strlen(password);
printf(" %d\n", i);
for(z =0; z <= i; z++)
{
if(password[ctr] == entry[ctr])
{
q++;
}
ctr++;
}
if(q == i)
{
printf("You are in\n");
}
else
{
printf("Access denied\n");
}
system("PAUSE");
return 0;
}