Help Me

i have created a program to take password from user while accessing a small project, but while user is inputting password it is displayed, i don't want it, i have created all other functions for deleting, editing password. e.g
enter password : india001 //i am getting that
enter password : ******* // i want my program look like that

is there is any function to implement this HELP !!!

use getch() to get a character without echoing it on the screen and print * for each entered character..and save each character in a char array

char pswrd[20];
    
    int i=0;
    while((pswrd[i]=getch())!='\r')
    {
    cout<<"*";
    i++;
    }

> is there is any function to implement this HELP !!!
There is no STANDARD function to do this, so in order to advise you properly, you need to tell us which OS/Compiler you're using.

The code posted by rajatC will not work if the user enters a backspace anywhere.
For e.g., inda[backspace char here]ia001.

Also, you would not want the user to leave any whitespace in between.

What you need to add is, check the scancode of the character. Then print a '*' only if it is not a backspace or any other whitespace.

yeah ofcourse you have to check for those condition jishnu is right...
i just gave an idea with that example..

use getch() to get a character without echoing it on the screen and print * for each entered character..and save each character in a char array

char pswrd[20];
    
    int i=0;
    while((pswrd[i]=getch())!='\r')
    {
    cout<<"*";
    i++;
    }

this is not working in cpp

this is not working in cpp

Then your compiler doesn't support getch(). That's the risk of using non-portable constructs. If you want help getting it to work, please start a new thread.

This article has been dead for over six months. Start a new discussion instead.