Skip to content

Instantly share code, notes, and snippets.

@theriverman
Created February 11, 2019 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theriverman/b41daa62f5013126b77790b8165fcf74 to your computer and use it in GitHub Desktop.
Save theriverman/b41daa62f5013126b77790b8165fcf74 to your computer and use it in GitHub Desktop.
C++ CLI Password Prompt Example
/*
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