Tuesday, August 16, 2011

Saving the password in an array

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
char ch;
char pw[100];
int i=0;
clrscr();
printf("Enter the password:\n");
ch=getch();
while(ch!=13)
{
if(ch==8)
{
printf("\b");
putch(NULL);
printf("\b");
pw[i]='\0';
--i;
}
else
{
printf("%c",ch);
putch('\b');
printf("*");
pw[i++]=ch;
}
ch=getch();
}
pw[i]='\0';
printf("\npassword is:%s",pw);
getch();
}