title: password masking in ubuntu in C++
body: <p>I recently made a program which uses <code>getch()</code> to mask the password entered. But it gives access as soon as the correct code is entered without waiting for enter key to be pressed. what changes should be done? Also, is <code>getch()</code> allowed in Ubuntu? If not, what alternative is to be used?</p>
  
  <p>My code looks like this. I already gave default password in a different function.
  </p>
  
  <pre><code>char pass[4];
  cout &lt;&lt; "\nEnter Administrator Password: ";
  for (i = 0; i &lt; 4; i++)
  {
    pass[i] = getch();
    cout &lt;&lt; "*";
  }
  for (i = 0; i &lt; 4; i++)
  {
    if(admin_pass[i] == pass[i])
      return 1;
    else
      return 0;
  }
  </code></pre>