954,141 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Input a "password" string

I :cheesy: want to input a string but instead of showing the real characters on the screen, i want all to be astericks. Can anybody help me to solve this?

hail2dthief
Newbie Poster
10 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

On a windows dialog? In VC++ you can edit the properties of an edit control and one of the properties is to use asterisks instead of text for password fields.

Chainsaw
Posting Pro in Training
436 posts since Jun 2004
Reputation Points: 36
Solved Threads: 11
 

No, not on a windows dialog. Actually i'm writing a program in dos mode and want to set up a password. Is there any c++ function that can help me to solve this?

hail2dthief
Newbie Poster
10 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

tHis is just my guess but try doing.....
cout << "* ";
is that what your talking about?

hfick
Newbie Poster
18 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

No, that's not what i'm talking about. What I want is when I enter a string, the asterisks will come out on the screen. Just like when you enter your password to log in to this website.

hail2dthief
Newbie Poster
10 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 
No, that's not what i'm talking about. What I want is when I enter a string, the asterisks will come out on the screen. Just like when you enter your password to log in to this website.

Please reread the part of that link that describes exactly that.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Thanks, Dave. I'll try it out and see if it can sole the problem or not.

hail2dthief
Newbie Poster
10 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 
//Warning,written by hand.Mistakes are possible

void pass(char *s,int len,char mask='*')
{
     int loc = 0;
     char p;
     int x = getx();
     int y = gety();

    do
      {
          p = getch();
          if(p == '\r')           // \r = enter
          {
                s[loc] = 0;
                break;
          }
          else if(p == '\b')   // \b means backspace
          {
               if(loc>0)
               {
                       s[loc]=0;
                       loc--
                       gotoxy(x-1,y);
                       cout<<" ";
                       gotoxy(--x,y);
               }
          }
          else
          {
                s[loc++] = p;
                 x++;
                cout<<m;
          }

     }
    while(true);
}
FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 

Thanks, guys. Problem solved.

hail2dthief
Newbie Poster
10 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You