CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    How to display password as '*' in DOS program

    In a console program, I would prompt the user for a password.
    Can someone show me the code on how to accept the input characters
    and display them on the screen as a string of '*'s ?

    Thanks.


  2. #2
    Guest

    Re: How to display password as '*' in DOS program

    #include <stdio.h>
    #include <conio.h>

    void main(void)
    {
    printf("Enter Password:");
    char pw[65];
    int i;
    i = 0;
    char c;
    c = _getch();
    while(c != char(0x0D) && i < 64)
    {
    putch('*');
    pw[i] = c;
    i++;
    c = _getch();
    }
    pw[i] = 0x00;
    printf("\n\nPassword entered was:%s\n",pw);

    }




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured