Thread: Making password into asterisk help.......!

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    5

    Post Making password into asterisk help.......!

    Hi guys,

    need a little help here.

    Do anyone here know how to put password into asterisk like (*) from the C coding below?

    Thanks and appreciate your help.


    Code:
    void main()
    {
    char userid[]="user",password[]="password",p[15],u[15];
    int n=1,a,b;
    printf("\nEnter username and password below (You have only three chances to enter)");
    getch();
    while(n<=3)
    {
    system("cls");
    printf("\nUsername: ");
    scanf("%s",u);
    printf("\nPassword: ");
    scanf("%s",p);
    a=strcmp(u,userid);
    b=strcmp(p,password);
    if(a==0&&b==0)
    {
    printf("\nYou have logged in successfully.");                //Put in the main();
    break;
    }
    else
    {
    printf("\nWrong password and/or username. Now you have % d more chance/s.",3-n);
    }
    getch();
    n++;
    }
    if(n==4)
    printf("\nYou can't log in.");
    getch();
    }
    Last edited by Salem; 08-30-2011 at 01:29 PM. Reason: Fix font abuse - this will be the last time I do this

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Turn off the big fonts... they have the exact opposite of the effect you're looking for...

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,907
    Read all of the following:

    Fix your oversized font, your crappy indentation, your incorrect usage of main and the missing return 0 at the end.

    I have a strong suspicion you're using Borland Turbo C. If so, consider upgrading to: Pelles C, Code::Blocks (with MinGW), GCC or even MS Visual C++ Express. They're all free and 20 years newer than that old 16-bit piece of crap Turbo C.

    As for your actual qustion, what you are trying to do is not as simple as calling something like "enable_password_asterisk_mode()". Are you sure you want to get into the mess of terminal manipulation or using ncurses for what seems like a simple assignment?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    Search:
    Keyword(s): password, asterisk

    Not to mention that it's been discussed many times before.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Last edited by Salem; 40 Minutes Ago at 03:29 PM. Reason: Fix font abuse - this will be the last time I do this
    Why do I doubt that???

    C'mon, we all know you'll have to do it again....

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Why do I doubt that???

    C'mon, we all know you'll have to do it again....
    You missed a great opportunity to do this.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    You missed a great opportunity to do this.
    Quzah.
    Actually, I chose to exercise the better part of judgement and not do that

  8. #8

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Asterisk Password
    By adnilsah017 in forum C Programming
    Replies: 4
    Last Post: 05-29-2011, 12:16 PM
  2. Replies: 2
    Last Post: 01-07-2009, 10:35 AM
  3. Password Asterisk
    By $l4xklynx in forum C Programming
    Replies: 5
    Last Post: 10-30-2008, 03:08 PM
  4. masked with asterisk(*)?
    By ShadeS_07 in forum C Programming
    Replies: 32
    Last Post: 10-25-2008, 12:16 PM
  5. Display input(password) as asterisk(*)
    By seePLUSPLUSn00b in forum C++ Programming
    Replies: 5
    Last Post: 09-29-2008, 11:16 AM