Thread Closed

C++ Password character echo

 
Share Thread Thread Tools
Jul14-10, 05:49 AM   #1
 

C++ Password character echo


The problem statement, all variables and given/known data

Currently using stdio.h, conio.h, string.h, stdlib.h
not using iostream, namespace std etc.

I am asked to make a password prompt where each character echoes an asterisk (*)

The user must be able to backspace and delete to make corrections.

The password is then stored in an array which can accomodate up to 100 passwords.

The attempt at a solution

count=0;
while(c != eof())
{
`c=getch();
if (c != eof())
{
printf("*");
c=pw[userid][count];
count++;
}
}
pw[userid][count] = '\0';

sadly, the output indentation looks horrible and it is uneditable using backspace and delete.
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> King Richard III found in 'untidy lozenge-shaped grave'
>> Google Drive sports new view and scan enhancements
>> Researcher admits mistakes in stem cell study
Jul15-10, 11:44 PM   #2
 
Blog Entries: 1
Recognitions:
Science Advisor Science Advisor
As I recall, getch returns any key presses. This includes control characters, such as, say, the backspace character (ASCII 0x08):
http://en.wikipedia.org/wiki/ASCII

You might also want to do some input filtering to ensure that only characters you want accepted actually are (again, look at the ASCII table). Lastly, rather than go crazy with allowing the user to edit and change the password, you might want to consider using a "Please type password again", just to make sure the user is entering both the same.

Good luck!
Thread Closed

Tags
c++, character echo
Thread Tools


Similar Threads for: C++ Password character echo
Thread Forum Replies
What are the meaning of monopole character and dipole character? Special & General Relativity 2
Get the contents of a file, character by character Programming & Comp Sci 7
The echo Introductory Physics Homework 9
echo in the ocean Introductory Physics Homework 2