X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-id: Date: Thu, 07 Mar 2002 08:20:03 +0300 Subject: Re: password and masking To: djgpp AT delorie DOT com Cc: djgpp AT delorie DOT com From: "NirinaMichel Ratoandromanana/DS-INFO" References: In-Reply-To: MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Reply-To: djgpp AT delorie DOT com Erratum: the correct code should be this: unsigned char *getpwd (char prompt[], char *password) { unsigned char *p = password; int c; printf ("%s", prompt); while (1) { c = getch(); //get char without echo, see getch vs. getche // terminate on end of line or file ^j, ^m, ^d, ^z if (c == '\r' || c == '\n' || c == '\004' || c == '\032') break; else if (c == '\b') { p--; //to get back and erase the previous * and get back again printf ("\0x1B \0x1B"); continue; } else { printf ("*"); *p++ = c; } } *p = '\0'; printf ("\n"); return p; } Nirina.