We all know that C doesnt not provide us with any function to enter a password so that whatever we type doesnt get on the screen.
I had this problem and i have found a solution. i have made a funtion

CODE
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
getpassword(char[]);
getpassword(char password[100])
{
char a;
int ab=0;
while(1)
{
fflush(stdin);
a=getch();
if (a>47 && a<123)
{
password[ab]=a;
ab++;
}
else if(a==8)
{
if(ab>0)
ab--;
}
else if(a==13)
{
password[ab]='\0';
break;
}
}
}


In turbo C++ 3.0
you can for e.g. call the function getpassword(char pass) which returns the string to pass.

Notice from BuffaloHELP:
Learn to use correct bbcode for CODEs posted.

 

 

 


Reply