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.
Printable View
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.
#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);
}