Monday, 25 August 2014

C Program to Input Password for Validation of User name

Here is C program to input password for Validation of User name is given ,which takes password and verify the name of user.
C Program to Input Password for Validation of User name


C Program to Input Password for Validation of User name 


#include<stdio.h>
#include<conio.h>
void main() {
   char password[25], ch;
   int i;
   clrscr();
   puts("Enter password : ");
   while (1) {
      if (i < 0) {
         i = 0;
      }
      ch = getch();
      if (ch == 13)
         break;
      if (ch == 8) /*ASCII value of BACKSPACE*/
      {
         putch('b');
         putch(NULL);
         putch('b');
         i--;
         continue;
      }
      password[i++] = ch;
      ch = '*';
      putch(ch);
   }
   password[i] = '\0';
   printf("\nPassword Entered : %s", password);
   getch();
}

Output



Enter password : **********
Password Entered : geekcoderz