hi guys . i run this code but when i input the password it dosent show star against password . whats the problem ?

#include <iostream>
#include "conio.h"
using namespace std;

int main()
{
    const int pass = 6004;
    char ch = 0;
    int ans = 0;
    cout << "Please enter your password to login :";
    cin >> ans;
    while ((ch = getchar()) != 13)
        if (ch >= '0' && ch <= '9')
        {
        cout.put('*');
        ans *= 10;
        ans += (ch - 48);
        }
    if (ans == pass)
        cout << "Welcome to my test program";
    else
        cout << "Login fail !\n" << "You entered wrong password"; //end if lopp
    _getche();
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.