Hi, good day.
I am making a password log in interface.
I make my input appear as *
The problem that I face is that when I press either backspace or enter, they are also counted as a character until the array is fulfilled.
Why is this so? Did any part of it goes wrong?
"When reading a function key or an arrow key, the function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code."
It means you test the value returned by getch (or _getch). If it is 0 or 0xE0 then you must call the function a second time to find which key was actually pressed.
No. In your program, you only need getch(). Forget about getwch(), that's just a distraction.
1 2 3 4 5 6 7 8
keypwd = getch();
if (keypwd == 0 || keypwd == 0xE0)
{
keypwd = getch();
// You will probably need additional code here
// to carry out the required action depending
// upon which special key was pressed.
}