![]() |
|
#1
|
|||
|
|||
help with getting single charI'm new to C++ and I cant figure out how to get a single char from the user without them haveing to hit enter
example: I hit 'A' and 'A' is stored int a varable but I dont hit enter Any help would be great |
|
#2
|
|||
|
|||
|
Usually doing a cin, the input is buffered in memory until the return key is hit.
If you turn off input buffering temporarily, using the www.cplusplus.com function, then reactivate it after for parformance sake, that might do the trick. GF |
|
#3
|
|||
|
|||
|
I was wondering about this also... could you elaborate on how to use "c setbuf()"?
thanks |
|
#4
|
|||
|
|||
|
I was wondering about this also... could you elaborate on how to use "c setbuf()"?
thanks |
|
#5
|
|||
|
|||
|
Sure, you could try something like this:
CPP / C++ / C Code:
I've no idea if this will work or not! GF |
|
#6
|
||||
|
||||
Re: help with getting single charWhy would you need to set a buffer you can just write
CPP / C++ / C Code:
|
|
#7
|
||||
|
||||
Re: help with getting single charBecause cin cannot read a keystroke and continue as SANman asked about 3 years ago. Anyway caracter is a buffer so you set one up too.
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#8
|
||||
|
||||
Re: help with getting single charVery Very sorry for wasting forum space. I probably diden't read the first entry properly.
|
|
#9
|
|||
|
|||
Re: help with getting single charQuote:
i don't know whether he has become ''old'' or not by now... but i think this would do... pls see the folloing.... CPP / C++ / C Code:
if you find the code any confusing, i think, i should join you in the search to get the same effect without using 'ncurses.h', because this is the simplest program that can be written with this library. but for now, i hope i have answered the '3-year old' question... in my best possible way ;-)) __________________
balu------>>>>>U perseverance pays slowly. |
|
#10
|
||||
|
||||
Re: help with getting single charQuote:
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C++ Irc Bot | Boogy | C++ Forum | 16 | 05-Aug-2006 14:04 |
| storing a token pointer as a string | CoreLEx | C Programming Language | 1 | 07-Oct-2003 12:33 |
| convert long to pointer to char | realpopeye | C++ Forum | 2 | 26-Sep-2003 11:22 |
| char to operator | calculus87 | C++ Forum | 3 | 04-Sep-2003 11:05 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The