One thing about IfYouSaySo's code is that you'll have to put in some stuff into the loop to change the array accordingly when backspace has been pressed or something. I made one like this:
Code:
void hide_typing (char WORD_TO_HIDE[300], bool hide)
{
char key;
for (int length=0; length<300; length++)
{
key = getch();
if ( (char)key == 13 ) // Return
{
break;
}
else if ( (char)key == 8 ) // Backspace
{
if ( length == 0 )
{
cout<< NULL;
}
else
length--;
WORD_TO_HIDE[length]=NULL;
cout<< (char)8 //backspace
<< (char)0 // nothing
<< (char)8; // back again
length--;
}
else
{
WORD_TO_HIDE[length]=key;
switch (hide)
{
case 0:
cout<< (char)15;//outputs stars
break;
case 1:
cout<< key;//outputs key
break;
}
}
}
cout<< "\n";
}
All teh (char)NUMBER's should be changed to VK_REFERECE's to make it look better, but sure, it works. You could change the function to a string easily enough too.
Code:
char thing[300];
hide_typing (thing, false );//Shows Text
hide_typing (thing, true);//HidesText
EDIT: WORD_TO_HIDE is kinda deceptive because I (for some unknown reason) choose to put it in all caps ... it shouldn't be. That's generally a lighthouse for marcos and proprossor stuff, so change that if you're going to use this