Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password creation

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how can i create a password using C, in such a way that when i encode the password it will apear in asterisk symbol?
 
Hey... this should work. It looks kinda sloppy, but it will print a '*' for each character typed. You will want to add code to make sure they do not type in more characters than are allowed, etc. But keep this basic structure to echo '*' characters.

int main() {

char c;
char pwbuff[32];
int j;

c = getch();
for (j=0; c != '\r'; j++) {
pwbuff[j] = c;
putc('*', stdout);
c = getch();
}
pwbuff[j] = 0;
printf ("%s\n", pwbuff);

return 1;
}
 
Just a side note as well... The '\r' character works for Windows because that is what is sent when you press return. For other operating systems I don't know if it sends '\r' or maybe '\n'. Try both out.

-Skatanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top