CrazyEngineers
  • C Program : Password Input Problem

    Vishal Sharma

    Member

    Updated: Oct 12, 2024
    Views: 1.0K
    1. while((c=getch())!=13)
    2. {
    3. pass[z++]=c;
    4. printf("%c",'*');
    5. }
    I used this while loop to take the input of the password. Everything works fine until no "wrong" key is pressed.
    the problem is, suppose, if i press a wrong key n i want to delete it (backspace) then even backspace is taken as a character.. How to rectify the code??
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • rahul69

    MemberAug 26, 2012

    Apply condition : If backspace then decrement the counter and continue
    For screen move a step back and replace * with ' '

    😎. Specify if any other doubt 😀
    Gud luckk
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 26, 2012

    yeah i've did it this way before but the thing is, using a whitespace disturbs the password and even the buffer memory is getting wasted in this way..
    I got it now 😀 that too in more efficient way.. using fflush() and fputs()
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register