How do I mask TEXT for example...
The programn askes you input password
then you put in your password but how do you mask it so you cant acually see the letters?
How do I mask TEXT for example...
The programn askes you input password
then you put in your password but how do you mask it so you cant acually see the letters?
You need an input method that does not echo to the screen. Then you could just replace the input (character by character) with another character such as an asterisk, or not at all. Do a search this has been discussed many times on these boards.
you could do something like this:
im not exactly sure, and i cant compile it ATM, but u can try itCode:#include <conio.h> #include <iostream.h> //.. char a; char password[255]; while((int)a != 27) { a = getch(); if((int)a != 27) { cout << "*"; strcat(password, a); } }
"There are three kinds of people in the world...
Those that can count and those that can't."
Is 27 the ascii code for the carriage return, so the loop will condition will become false as soon as the user hits enter?
Be a leader and not a follower.
Here is a function I think you might be able to use. It is a function to input a password with a limiting length of 25 characters...
#include<iostream.h>
#include<conio.h>
void getpassword(char *string)
{
for(int counter=0; counter<maxlength; counter++) //maxlength is the maximum size of the string. This loop is for the purpose of making all elements of the string null.
string[counter]=0;
int *len=new int; *len=0; char c=0;
while(c!=13)
{
c=char(getch());
if(*len<=24)
{
if(*len!=0 && c=='\b')
{
string[*len-1]=0; gotoxy(wherex()-1,wherey()); clreol(); (*len)--;
}
if(*len!=0 && c=='\b' && wherex()==1)
{
string[*len-1]=0; gotoxy(80,wherey()-1); (*len)--;
}
if(c!='\b' && c!=13)
{
cout<<"*";
string[*len]=c; (*len)++;
}
if(c==13)
{
cout<<endl;
}
}
if(*len>=25 && c=='\b')
{
string[*len-1]=0; gotoxy(wherex()-1,wherey()); clreol(); (*len)--;
}
}
delete len;
}
Compiler:Borland C++ 5.0
Last edited by sundeeptuteja; 07-03-2002 at 05:07 AM.