who knows how to show asterisks instead of the user's input in c++ ??
someone said something a/b masking or turning off echo ???
JR
const int passwdLength = 16;
char passwd [passwdLength];
for(int i=0; i <= passwdLength; i++)
{
passwd[i] = getch();
if (passwd[i] == 13) break;
putch('*');
}
Needs some error handling/checking, but you get the idea...
well, if 'getch()' == cin.get() then thats not what im lookin for b/c the user still has to type (and the console is displaying what they are typing) and then hit enter before anything happens.
really, im looking for a trigger that something has been typed (one char). if i can get to that point, i can clear it and display *.
OR even easier, somehow turn off the user display for that statement....is it called echo ??
JR
In C programs we used to use curses.h which defined an echo() and noecho(). These controlled whether a character that was typed in was displayed by getch().
aaahhhh. that would explain me having no idea what getch() was. thanks dr. w
JR
Did you try compliling/running the code I posted? It does exactly what you are describing as I tested it before posting. BTW, my environment was Visual Studio 2003 on Windows XP. I'd be curious if you had different results on a same/different platform.
You have to include the conio.h library in vc++ to get getch and putch... Both of these commands disable echo by bypassing the input buffer. getchar and putchar enable echo.
#include
int main()
{
const int passwdLength = 16;
char passwd [passwdLength];
for(int i=0; i <= passwdLength; i++)
{
passwd[i] = getch();
if (passwd[i] == 13) break;
putch('*');
}
return 0;
}
sweet. conio.h did it. very cool. thanks guys
JR
This IS very cool!!! Thanks for the code! I'm going to go play with it some more. :-D