So what happens is, when I enter a backspace in this program, that a letter gets erased back. But if I keep pressing backspace for a longer time, -1 starts to get printed...
What is the reason for this and how can I fix this?
system("cls");
char password[25], temp;
char correctpass[10]="basket@123";
int f=0;
label:
drawBorder(5,3,100,24);
gotoxy(40,12);
printf("Enter the password : ");
while (1) {
temp = getch();
if (temp == 13)
break;
else if(f<0){
printf("%d",f);
}
else if (temp == 8){
printf("\b");
printf(" ");
printf("\b");
f--;
}
else{
password[f] = temp;
printf("*");
f++;
}
}
password[f] = '\0';