Write a program in c++ which show password as Stars or Dots

Understanding program requirements completely mean your problem is almost solved.In this Problem we need 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 Shows in Staric



Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment