C Program : Password Input Problem

  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??

Replies

  • rahul69
    rahul69
    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
  • Vishal Sharma
    Vishal Sharma
    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()

You are reading an archived discussion.

Related Posts

My name is Ravi I'm student now studying 3rd year betech ece in yogivemana university proddatur More intersted in doing mini project like radio TX and rx ,sensor based projects...
just a new member..please take care of me ๐Ÿ˜€ will anyone suggest an electronic project and can provide its circuit design.. and that is affordable.. please help me with this...
Columns are vertical members, For example: pillars. As far as beams are concerned. it is easy to represent the type of loads acting on them by means of free body...
What is the basic difference between electrical and electronics engineering? Is it based on voltages or there are other factors as well?
Why are the power system ratings designed as multiples of 11kV? The reason may be for similar calculations, but that doesn't sound logical. Could someone explain?