Code:
#include <stdio.h>
#include <conio.h>
void getpass(char*);
int main(){
char tpass[9];
printf("\nPlease enter your password:");
getpass(tpass);
while (tpass != "password"){
printf("\n\aWrong password! please try again:");
getpass(tpass);
}
}
/***********************************************/
void getpass(char* pass){
/* function variables */
char ch;
int flag = 0, i = 0;
/* function process*/
while(flag == 0){
ch = getch();
if (ch == '\r'){
if (i != 0){
pass[i] = NULL;
flag = 1;
continue;
}
printf("\a");
continue;
}
else if (ch == '\b'){
printf("\b");
i--;
continue;
}
printf("*");
pass[i] = ch;
i++;
}
}
I dont know why it go to while loop when I enter the pass word correctly!
this is a part of my whole code