|
-
Nov 3rd, 2002, 04:35 PM
#1
Thread Starter
<?="Moderator"?>
how is this done?
one some console program you have to enter any option, like a number or y,n and its enclosed in [ ] how is it done?????
Thanks
-
Nov 3rd, 2002, 04:56 PM
#2
Monday Morning Lunatic
On a Unix system, just print out a couple of backspace characters (\b) to move the cursor back.
I still haven't worked out how to get cin to return a single character yet though
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2002, 05:22 PM
#3
Thread Starter
<?="Moderator"?>
what about something like this
cin.getline(String, 1, *);
-
Nov 3rd, 2002, 05:24 PM
#4
Monday Morning Lunatic
Nope, can't use wildcards with that.
I think it needs to go down to the streambuf level Will take a look when I have some time.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2002, 05:46 PM
#5
Frenzied Member
char t;
cin.read(1, &t);
Might have to swap the parameters, I dont remember =).
Z.
-
Nov 3rd, 2002, 06:03 PM
#6
Monday Morning Lunatic
Tried it. It still needs you to hit return afterwards.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2002, 08:22 PM
#7
Frenzied Member
Oh, you mean realtime input. =)
Z.
-
Nov 3rd, 2002, 09:16 PM
#8
PowerPoster
You can probably use getchar() or some other function to know when a key is pressed and then you can check the keyboard buffer to know what key was pressed. Since I haven't programmed for a couple of months, I forgot how to do this...
-
Nov 3rd, 2002, 10:09 PM
#9
Junior Member
Originally posted by abdul
You can probably use getchar() or some other function to know when a key is pressed and then you can check the keyboard buffer to know what key was pressed. Since I haven't programmed for a couple of months, I forgot how to do this...
I believe that getchar() returns the character i gets as input, so you just assign it like this:
character = getchar();
Not sure on what arguments you'd need, but you could basically make a loop that gets the char, checks if it's [, then goes on checking each char in the string. I've done this before, it's really simple. I'll try and dig up the code.
-
Nov 3rd, 2002, 10:10 PM
#10
Frenzied Member
i had to make something to trap keys for school, it doesn't wait for input, if thats what you're looking for...it uses a thread and then runs getch()
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
|