Hello I am making a personal program that I can keep secret info, browse the web, play music, change the password, and a lot more. My problem is that when entering the password it won't let me use the backspace. (THE PASSWORD IS MASKED.)
Is there any way to make the backspace not be counted as a char and actually delete a char?
Please help me and thank you in advanced for anyone who does help.
I Mean,Didn't You Just Ask How To Change Passwords On Websites?That Is Illegal if That's what you Mean.But Anyways,You Need To Use An Addalce Character,Sort Of Like The '\n' Thing.I Forget Which One Though.Example:
1 2 3 4
#include <iostream>
int main(){
std::cout <<"He \n He";
}
#include <iostream>
#include <conio.h>
#include <string.h>//may be called something else on your compiler
usingnamespace std;
int main()
{
string pswd = "";
char pswd_ch;
cout<<"Enter password: ";
pswd_ch = _getch();
while(pswd_ch != 13){// ASCII 13 is enter
switch (pswd_ch){
case 8:
pswd.push_back(pswd_ch);
cout<<"\b";
pswd_ch = _getch();
break;
default:
pswd.push_back(pswd_ch);
cout<<"*";
pswd_ch = _getch();
break;}//Yes, I know it's not secure, does it need to be?
}
if(pswd == "Demonstration"){
cout<<"Good pasword. Accessing...\n";
return 0;
}
else{
cout<<"FAIL!!!";
return 0;
}
}
Then do what you want with it. For example, instead of my literal in the password check, use a string, call it right_password or something like that. Have it defined in a hard-to-open file where the program can go get it (#include <fstream>). Then, under the password change section, use the same principle using getch() instead of _getch() and ignoring the cout in the password check.