simple password program problem in c++
i m beginners of c++ and i want to make simple password program that will accept password from user and simultaneously display the stars("*") with the simple while loop.
i have written the code of this program but this is showing wrong result.Pls help me in solving this problem.
The Code :
#include<iostream.h> #include<conio.h> void main() { clrscr(); char pwd[5]; int i=0; while(i<5) { pwd[i]=getch(); cout<<"*"; ++i; } cout<<pwd; if (pwd=="sumit") cout<<"correct password"; else cout<<"wrong password"; getch(); }