hey guys, i'm using Borland 6 c++ in windows xp, now that we got that i have a problem with my program, i have recently created a password function in a programm that works so that when they try to type in their password it shows the * instead of the character for security measures (and just cus it is cool too lol) but the problem is that when someone makes a typo and wants to delete a character it still displays another *, is there a way that i can make the programm destroy one character when the backspace button is struck? here is my function so that you guys can look at it too.
hey guys, i'm using Borland 6 c++ in windows xp, now that we got that i have a problem with my program, i have recently created a password function in a programm that works so that when they try to type in their password it shows the * instead of the character for security measures (and just cus it is cool too lol) but the problem is that when someone makes a typo and wants to delete a character it still displays another *, is there a way that i can make the programm destroy one character when the backspace button is struck? here is my function so that you guys can look at it too.
//************Program for entering password of max 8 characters**************/
//************Press backspace if you make a mistake in the middle************//
//************Press Enter once you are done**********************************//
void main()
{
clrscr();
int i=0,j;
char ch,temp[8],arr[8],*password;
strcpy(arr,"");
while(i<9)
{
ch=getch();
if(i==8&&(ch==13))
break;
if(ch==8)
{
if(i!=0)
i--;
}
else
if(ch==13&&i<8)
{
temp[i]='\0';
break;
}
else
if(i<8)
{
temp[i]=ch;
arr[i]='*';
i++;
}
clrscr();
gotoxy(1,1);
for(j=0;j<i;j++)
cout<<arr[j];
}
password=newchar[i];
for(j=0;j<i;j++)
password[j]=temp[j];
password[j]='\0';
cout<<"\nThe Password you typed is :";puts(password);
getch();
}
I just wrote this small program.I know there may be 100 better ways to write it but this was the first program I wrote for handling passwords.You can always use the getpass() function but there is a catch with that.
Um... hello? This thread is like 2 years old, and plus your code isn't the finest quality... (like using void main and outdated headers)
hmm..yes..That was before I joined this forum.Actually that was just my first post.I stumbled upon that by mistake and didnt see the date..And yeah I was really ignorant of the fact that you should never use void main().And the reason very obvious.."My teachers never told me it was wrong"..Anyways thats not an excuse..And about the outdated header..As I said that was written a long time ago on a now outdated Borland C++ 3.0..So its all my mistake..
Last edited by crazylunatic; Mar 31st, 2007 at 12:20 am.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.