Paste Code
Paste Blends
Paste Images
#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std; //needed for cout and etc

int main()
{
START:
system("cls");
cout<<"\nEnter Password : ";
char pass[32];//to store password.
int i = 0;
char a;//a Temp char
for(i=0;;)//infinite loop
{
a=getch();//stores char typed in a
if((a>='a'&&a<='z')||(a>='A'&&a<='Z')||(a>='0'&&a<='9'))
//check if a is numeric or alphabet
{
pass[i]=a;//stores a in pass
++i;
cout<<"*";
}
if(a=='\b'&&i>=1)//if user typed backspace
//i should be greater than 1.
{
cout<<"\b \b";//rub the character behind the cursor.
--i;
}
if(a=='\r')//if enter is pressed
{
pass[i]='\0';//null means end of string.
break;//break the loop
}
}
cout<<"\nYou entered : "<<pass;
//here we can even check for minimum digits needed
if(i<=5)
{
cout<<"\nMinimum 6 digits needed.\nEnter Again";
getch();//It was not pausing :p
goto START;
}
return 0;
}
//Lets check for errors.
//You can even put file system.
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. using namespace std; //needed for cout and etc
  5.  
  6. int main()
  7. {
  8.     START:
  9.     system("cls");
  10.     cout<<"\nEnter Password  : ";
  11.     char pass[32];//to store password.
  12.     int i = 0;
  13.     char a;//a Temp char
  14.     for(i=0;;)//infinite loop
  15.     {
  16.         a=getch();//stores char typed in a
  17.         if((a>='a'&&a<='z')||(a>='A'&&a<='Z')||(a>='0'&&a<='9'))
  18.         //check if a is numeric or alphabet
  19.         {
  20.             pass[i]=a;//stores a in pass
  21.             ++i;
  22.             cout<<"*";
  23.         }
  24.         if(a=='\b'&&i>=1)//if user typed backspace
  25.         //i should be greater than 1.
  26.         {
  27.             cout<<"\b \b";//rub the character behind the cursor.
  28.             --i;
  29.         }
  30.         if(a=='\r')//if enter is pressed
  31.         {
  32.             pass[i]='\0';//null means end of string.
  33.             break;//break the loop
  34.         }
  35.     }
  36.     cout<<"\nYou entered : "<<pass;
  37.     //here we can even check for minimum digits needed
  38.     if(i<=5)
  39.     {
  40.         cout<<"\nMinimum 6 digits needed.\nEnter Again";
  41.         getch();//It was not pausing :p
  42.         goto START;
  43.     }
  44.     return 0;
  45. }
  46. //Lets check for errors.
  47. //You can even put file system.
  48.  
go to heaven