Thread: Any method to mask the password that the user entered?

  1. #1
    Registered User FCF's Avatar
    Join Date
    Dec 2001

    Question Any method to mask the password that the user entered?

    I am a college student and i received an assignment last week. I think i am able to complete the assignment but in the password section, i think my program will be better if the password that the user entered will be masked by my program. My program needs the user to enter their IDs and passwords through the keyboard. My idea is : Any method to mask the password while the user is typing the password ? I afraid that someone will not understand my question... I mean if i press "9" on the keyboard then the "9" will appears on the monitor, but now i want to mask the "9" with anything such as the asterisk "*". Any suggestions ? Please mail to me if you have any idea.

  2. #2
    You can use a function to read the string that doesn't display the char on the screen and then echo a '*'

    #include <stdio.h>
    #include <conio.h>
    int main()
    	char password[100];
    	int i=0;
    	password[i-1]='\0';//remove the newline
    	return 0;
    hope it helps

  3. #3
    Registered User
    Join Date
    Sep 2001


    If you're under *nix, you could try using readline(), although this might not be allowed.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Cannot be done with ANSI C. Check your compiler's BIOS functions, or keyboard functions. Basically, you want to just capture their key-presses. If you want to print something, say, asteriks, then you'll just have to add that to your function. Remember that by just capturing key-presses, you'll have to have special cases for <ENTER> and <BACKSPACE>
    Callou collei we'll code the way
    Of prime numbers and pings!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. on method pointers and inheritance
    By BrownB in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2009, 07:50 PM
  2. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  3. Password program problem.
    By netboy in forum C Programming
    Replies: 3
    Last Post: 12-22-2001, 09:54 AM
  4. use user entered formula to calculate something
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 12-07-2001, 02:21 AM
  5. password
    By hammers6 in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 12:14 AM