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?

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.

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?

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

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.

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.

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

//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);
}

Thanks, guys. Problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.