title: Program for Password in C++
body: <p>Password program not working....pls help....for right input also it says wrong password</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt; 
  #include&lt;string.h&gt;
  #include&lt;iostream.h&gt;
  
  void main()
  {  
    clrscr();
    int ctr=0;
    int  o;
    char pass[5];
  
    cout&lt;&lt;"enter password";
    for(int i=0;i&lt;5 &amp;&amp; (o=getch())!=13  ;i++)
    {  
      pass[i]=o;
  
      putch('*');
    }
  
    ctr=strcmp(pass,"luck");
    cout&lt;&lt;ctr;
    if(ctr==0)
    {
      cout&lt;&lt;"welcome";
    }
    else
    {
      cout&lt;&lt;"wrong password";
    }
    getch();
  }
  </code></pre>
  
  <p>I want to know why this password program not working....is their any other way</p>