Quote:
> >How do you mask a character the user types in to something like this '*' in C?
> >Let's say that you typed in 'a', but it would show up as '*'. How would you do
> >that?
> Why don't you use "getch()"
Because there is no such function in standard C.
Quote:
> getch() will not show anything while getting user input.
No, getch() on YOUR compiler will do that.
Quote:
> So all you have to do is:
> Get user input with getch() and process each character with
> switch(). Then add followings inside the switch();
> if user input an alpha-numeric character, print an '*' on screen.
How would you do that in a switch?
case 'a':
case 'b':
case 'c':
case 'd':
...
case '0':
case '1':
...
etc., etc.
?
There's a perfectly good function called isalnum() which will tell you
if a character is alpha-numeric or not. It will most likely be faster,
smaller, and more portable than anything you can write.
Quote:
> if user press "backspace", delete an '*' on the screen.
> To learn more about "getch()", consult your compiler's help.
In comp.lang.c we only accept portable, standard answers. getch()
doesn't exist in standard C, and doesn't even exist in nearly as many
compilers as it used to, so it doesn't have any place in this newsgroup.
--
I believe we can change anything.
I believe in my dream.
- Joe Satriani