Exforsys
+ Reply to Thread
Results 1 to 2 of 2

how to make the password in to asterisk and asign a exact password for char.

This is a discussion on how to make the password in to asterisk and asign a exact password for char. within the C and C++ forums, part of the Programming Talk category; uhm.... excuse me but can you please help me? i'm having trouble with making password in TURBO c.... the condition ...

  1. #1
    liza12 is offline Junior Member Array
    Join Date
    Oct 2009
    Answers
    1

    how to make the password in to asterisk and asign a exact password for char.

    uhm.... excuse me but can you please help me? i'm having trouble with making password in TURBO c.... the condition goes like this, while the user is entering a password, the user will not see alpha-numeric characters instead, he/ she can see only asterisk... and the computer will read the password.
    if the password is 'liza' it will clear the screen and it will loading...if it`s not it will print 'failed to log-in'
    can you please tell me the code?????


    my only problem is how to asign password and the computer or the program will read the password

    here`s my code:


    Code:
    #include<conio.h>
    #include<stdio.h>
    main()
    {
    
    char *ptr;
    char pwd[150];
    char c;
    int a,x;
    int i=0;
    char password[15];
    
          clrscr();
    
          printf("ENTER PASsword");
    
    
    while(1)
    {
    
       gets(password);
       x=strcmp(password, "liza");
      c=getch();
    if(c==13)
    {
    
    pwd[i]=NULL;
    break;
    }
    
    printf("*");
    pwd[i++] = c;
    }
       if(x!=0)
       {
    	  printf("FAILED TO LOG-IN");
    	}
    
         clrscr();
    
          for(a=1;a<=80;a++)
        {
        gotoxy(a,1);printf("\xDB");
        gotoxy(a,24);printf("\xDB");
        delay(990);
        gotoxy(37,13);printf("LOADING!!!");
        }
    
    getch();
    }
    kindly help me..thnx in advance


  2. #2
    rasmiranjanbabu is offline Junior Member Array
    Join Date
    Oct 2009
    Location
    Bangalore, India
    Answers
    2

    Check it out

    I have run this code in VC++ 6.0.
    It works. Please check it out.

    #include<conio.h>
    #include<stdio.h>
    #include<string.h>
    //#include<graphics.h>
    main()
    {

    int c;
    int i;
    char pwd[80];
    // clrscr();

    printf("ENTER PASsword");


    for ( i = 0; i < 79 && (c = getch()) != '\r'; ++i )
    {
    pwd[i] = c;
    putch('*');
    }


    pwd[i] = '\0';
    printf("\n");;
    if ( strcmp(pwd, "liza") == 0 )
    {
    printf("Correct \n");
    }
    else
    {
    printf("INCorrect \n");
    }
    return 0;
    }


    I hope this helps you


Latest Article

Network Security Risk Assessment and Measurement

Read More...