|
-
Mar 7th, 2003, 01:10 AM
#1
Thread Starter
Addicted Member
I have a couple of questions...
In command prompt programming...
[list=1][*]How do you convert a user's input to asterisks as he/she is typing? [*]How do you detect if the user is typing characters that are non-numeric?[/list=1]
Thanks!
Rick
 Eat long and prosper! 
If someone helps you, find someone you can help.
If you still have time, click on the darn banner up there and help the forum! 
-
Mar 7th, 2003, 02:59 AM
#2
Addicted Member
I've never done this so I can't be more help but for #1, youll have to hook the keyboard to get the data before the screen does... I do know you can do this though.
I figure #2 is answered by this, just compare the hooked data to your known asc codes
Google Search!
NOMAD
-
Mar 7th, 2003, 11:35 AM
#3
Fanatic Member
getch() will allow for you to input characters without echoing them to the screen. Then cout *'s to the screen for each character entered.
Now, if you want backspace, that is a bit difficult. If you are using Borland C++, clrscr() contained in conio.h (yes, i know that this header is depreciated but I do not have access to my complier right now to check.) will allow you to clear the screen and then redisplay your screen.
Now for #2:
if ((character <= 'a' && character >= 'z') && (character <= 'A' && character >= 'Z'))
// It is an alphabetic character. (If you are supporting different languages, check for valid characters the same way as I did above.)
-
Mar 7th, 2003, 03:36 PM
#4
conio.h isn't deprecated but it isn't standardized. clrscr is only available in Borland though.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 7th, 2003, 04:16 PM
#5
Addicted Member
x = getch(); //will get the character the user gave
if( (x >= 48) && (x <= 57) // this will check the input is numeric
if( (x < 48) && (x > 57) ) //do the opposite, non-numeric
<stdlib.h> ( im pretty sure thats it, if not its got some letters in front of it )
allows you to call
system("clr");
to clear the screen if you can't use clrscr();
-
Mar 8th, 2003, 08:17 AM
#6
system("cls");
The DOS clear screen app is called cls, not clr. In UNIX it would be "clear".
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 8th, 2003, 04:22 PM
#7
Thread Starter
Addicted Member
Cool! I'll try it out and let you know what happens.
Thanks, guys!
Rick
 Eat long and prosper! 
If someone helps you, find someone you can help.
If you still have time, click on the darn banner up there and help the forum! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|