Click to See Complete Forum and Search --> : How to display password as '*' in DOS program


April 15th, 1999, 12:33 PM
In a console program, I would prompt the user for a password.
Can someone show me the code on how to accept the input characters
and display them on the screen as a string of '*'s ?

Thanks.

April 15th, 1999, 02:38 PM
#include <stdio.h>
#include <conio.h>

void main(void)
{
printf("Enter Password:");
char pw[65];
int i;
i = 0;
char c;
c = _getch();
while(c != char(0x0D) && i < 64)
{
putch('*');
pw[i] = c;
i++;
c = _getch();
}
pw[i] = 0x00;
printf("\n\nPassword entered was:%s\n",pw);

}