1. Convert Password into Stars
2. Convert Password into Dots
3. Convert Password into Character
Structure of the problem Requirements
understanding program requirement completely mean your problem is almost solved.In this Problem weneed a coating type logic to hide our words and show some stars or dots instead of password.Here
we take the ASCII value of the integer and alphabet and then concatenate them into string.
At the end of the code an output of the code is given with Screen Shoots,you try it match it
with out and practice it ....
Source Code
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
string password;
cout<<endl<<"ENTER PASSWORD : \n\n";
char c = ' ';
while(c != 13)
{
c = _getch(); //Command for Cin but it recieve as a single digit and Proceed it
if(c==13) // There is no character in 13
if(c==8) //There is no character in 13
{
if(password.size()!=0) //There is still no character but if any it eliminate it
{
cout<<"\b \b";
password.erase(password.size()-1); // By the decrement of 1
}
}
if((c>47&&c<58)||(c>64&&c<91)||(c>96&&c<123)) //ASCii code for integer and alphabet
{
password += c; //All the word are concatenate in the String password
cout << "*"; //Now On Screen all the words are display as a *
}
}
cout<<endl<<endl<<"Your Password: "<<password<<endl<<endl; // Again your password shown in word
return 0;
}
Output of the Program
Password shown in Staric |
Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.
0 comments:
Post a Comment