Created
February 11, 2019 23:03
-
-
Save theriverman/b41daa62f5013126b77790b8165fcf74 to your computer and use it in GitHub Desktop.
C++ CLI Password Prompt Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
For getUserPassword.hpp, see other gist. | |
Build: ++ examplePasswordPrompt.cpp -o examplePasswordPrompt | |
*/ | |
#include <iostream> | |
#include <string> | |
#include "getUserPassword.hpp" | |
using namespace std; | |
int main() | |
{ | |
std::string userPass; | |
std::cout << "Password: \n"; | |
SetStdinEcho(false); // turn off echo while getting password | |
std::cin >> userPass; | |
SetStdinEcho(true); // turn back on echo | |
// print password for verification | |
std::cout << "Password: " << userPass << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment