guidence

This is a discussion on guidence within the C++ Programming forums, part of the General Programming Boards category; i`m making a game were the user has to type in there password and instead of seeing the actual password ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    8

    guidence

    i`m making a game were the user has to type in there password and instead of seeing the actual password i need to know how to just show the *** sign


    just give me a link to a tutorial or something, i`m not asking for help i`m just asking for guidence

    -eldian()

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    Here's a quick and dirty way to do it using conio and getch. Substitute your own nonblocking read where appropriate:
    Code:
    #include <iostream>
    #include <string>
    #include <conio.h>
    
    using namespace std;
    
    static string getPass()
    {
        string pass;
        int i;
        int ch;
    
        while ((ch = getch()) != '\r')
        {
            if (ch == '\b')
                cout<<"\b\b  \b\b";
    
            pass += (char)ch;
            cout.put('*');
        }
    
        return pass;
    }
    
    int main(void)
    {
        string password = getPass();
    
        cout<<"\n"<< password <<endl; /* Test print: Does it work? */
    
        return 0;
    }
    p.s. What the alphabet would look like without q and r.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A little guidence needed
    By Matty_Alan in forum Game Programming
    Replies: 20
    Last Post: 12-17-2008, 06:41 AM
  2. guidence to a program C
    By nurofen in forum C Programming
    Replies: 17
    Last Post: 04-15-2008, 12:50 AM
  3. New program, guidence
    By RoD in forum C++ Programming
    Replies: 5
    Last Post: 12-06-2002, 06:36 AM
  4. Homework guidence, very important
    By RoD in forum C++ Programming
    Replies: 4
    Last Post: 12-04-2002, 07:28 PM
  5. Need some Guidence
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2001, 09:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21