title: Password masking (input displayed as ********)
body: <p>I wrote a program that gets the input from user to enter his username and password but what i want is that when user inputs his password it is displayed as ***** and not in english just like when we enter password in Gmail.</p>
  
  <p>I researched on internet and i have managed to write this program but i can't input anything in the password.Also i dont fully understand the code that i have written.</p>
  
  <pre><code>class user
  {
  private:
     string name;
     string pass;
  public:
                  void mask()
  {
          char c;
          for(int i=0;i&lt;100;i++)
          {
                  c=getch();
                  if(c=='\r')
                          break;
                  std::cout&lt;&lt;"*";
                  pass=pass+c;
          }
  }
          void getdata()
          {
                  int flag=0;
                  do
                  {
                  cout&lt;&lt;"Enter username: ";std::getline(std::cin,name);
                  cout&lt;&lt;endl;
                  cout&lt;&lt;"Enter password: ";mask();
                  cout&lt;&lt;endl;
                   if((name=="myname")&amp;&amp;(pass=="tiger"))
                          {
                                  cout&lt;&lt;"\n\nLogin successful"&lt;&lt;endl;
                                  flag=1;
                          }
                  else
                          cout&lt;&lt;"\n\nInvalid username or password\n\nHint:Your username and password is myname and tiger"&lt;&lt;endl&lt;&lt;endl;
          }while(flag==0);
          }
  };
  </code></pre>