标签:c++
#include <iostream> #include <vector> #include <conio.h> using namespace std; int main() { vector< char > password; int len = 0; cout << "Enter password: "; while( true ){ char ch = getch(); if( ch == 13 ) break; if( ch == 8 ){ if( len == 0 ) continue; len--; cout << "\b \b"; password.pop_back(); } else{ len++; cout << '*'; password.push_back( ch ); } } cout << endl; for( int i = 0; i < password.size(); ++i ){ cout << password[i]; } return 0; }
标签:c++
原文地址:http://blog.csdn.net/pandora_madara/article/details/35797091