Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- /* compile using -std=c++17 */
- using
- std::cin,
- std::cout,
- std::endl,
- std::string;
- /* get input stright off cli
- on keypress
- https://replit.com/talk/learn/Detecting-keypresses-in-c-without-pressing-enter/28460
- */
- int keypress() {
- system ("/bin/stty raw");
- int c;
- c = getc(stdin);
- system ("/bin/stty cooked");
- return c;
- }
- int main(){
- string ast;
- int d=0,key;
- do {
- key = keypress();
- /* 13 is the ascii number
- for return key */
- if(key == 13)
- break;
- #ifdef __linux__
- system("clear");
- #elif __WIN32
- system("cls");
- #endif
- cout << key << " ";
- /* keep adding * to string
- then update cli */
- ast +="*";
- #ifdef __linux__
- system("clear");
- #elif __WIN32
- system("cls");
- #endif
- std::cout << ast;
- d++;
- } while (1);
- char c;
- string password,
- pwcheck="mypasswd";
- cout<<"enter password\n";
- /* loop condition: get a character,
- while it isn't a newline
- (end of password), */
- while ((c=getchar()) != '\n')
- {
- // put it onto the back of the password
- password.push_back(c);
- // output a '*' character
- putchar('*');
- }
- if(password != pwcheck)
- cout<<"your password no good\n";
- else
- cout<<"password matched\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement