Results 1 to 2 of 2

Thread: Using putback for passwords

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Using putback for passwords

    I'm trying to hide the password as the user enters it, but for some reason it's not working. it seems like an infinite loop:


    Code:
    string get_password()
    {
       string give_back;
       char temp;
       while(cin.get(temp) != 0)
       {
          //give_back += temp;
          cin.putback('*');
          
       }
       
       return give_back;
    }

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Using putback for passwords

    putback() doesn't do what you think. Look it up.

    There is no way in standard C++ to achieve what you want. It's only possible using platform-specific API.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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