When inputting '*' password...a char comes already.....

Its menu driven prog.
When It asks for inputting a char of choice option 'a'/'b'/'c'....
A char comes already before inputting (statment: cin>>ch;)
I first rub it <BACKSPACE>,,,,,,the enter my choice.......

The further I require to input a passphrase...using a funcn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void getpass(char pass[])
{
	char ch;int i=0;
	while(1)
	{
	 ch=getch(); 
	 if(ch!='\b'&&ch!=13)
	 {	cout<<"*";
		pass[i++]=ch;  }
	 else if(ch!=13)
		{  if(i>0)
			{cout<<"\b \b";
			i--;}
		}
		else {  pass[i]='\0';
			return;       }
	}



The funcn works correctly....BUT its necessary to have nothing preTYPED while entering a password.......
PLZ HELP/////////////////////////////////////////////////////////////////


Usually that preInputted char is 'H' I have to rub this.......HOW TO GET RID OF THIS.............
Last edited on
Not meaning to be rude, but please, edit your post and write this all once again. If you use tons of '/' or '.', nobody will look at it. Really. If you put ten exclamation marks, it won't be louder. It will be more annoying.

I would be glad to help you, but I can't understand your problem, when you use such style. Same goes for "funcn" or "plz". If you write your question calmly, and you describe your problem well and clearly ask question, then I am sure that someone will come by and help you.

But in your code, there is high probability that you will have infinite loop. Also, please add comments so we can understand it better. And, even better, don't use magic numbers :)

Cheers!
THANKS MATTHEW ROCK....LET ME THINK ...that how should i PUT this....
Topic archived. No new replies allowed.