3.write A Program For The Printed Passwords
3.write A Program For The Printed Passwords
#include <iostream>
#include <stdio.h> // Needed for getchar()
using namespace std;
enum IN {
IN_BACK = 8,
IN_RET = 13
};
while (true) {
ch_ipt = getchar(); // Fixed: getchar() requires <stdio.h>
if (ch_ipt == IN::IN_RET) {
cout << endl;
return passwd;
} else if (ch_ipt == IN::IN_BACK && !passwd.empty()) {
passwd.pop_back();
cout << "\b \b"; // Erase the last '*' from the console
continue;
} else if (ch_ipt == IN::IN_BACK && passwd.empty()) {
continue;
}
passwd.push_back(ch_ipt);
cout << sp; // Print '*' instead of the actual character
}
}
int main() {
string name;
string input;
cout << "\nEntered Password: " << input << endl; // Display password for
testing
return 0;
}