473,394 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How watch for and extract single char from cin?

I guess I'm more of a newbie than I'd thought. I simply want to wait for at
least one byte (character?) to appear and then cin.get() or cin.read() that
character - without waiting for some delimiter to appear. I would have
thought this would be a common pattern for event-driven keystroke processing
but I can't find any examples of how it would be done using c++ iostreams.

Can someone point me toward a book, article, or example?

TIA

--
"Anyone who considers arithmetical methods of producing random digits is, of
course, in a state of sin." John von Neumann (1951)
Sep 13 '05 #1
1 1540
On Mon, 12 Sep 2005 18:15:40 -0700, "Dick Bridges"
<db******@codecomplete.com> wrote in comp.lang.c++:
I guess I'm more of a newbie than I'd thought. I simply want to wait for at
least one byte (character?) to appear and then cin.get() or cin.read() that
character - without waiting for some delimiter to appear. I would have
thought this would be a common pattern for event-driven keystroke processing
but I can't find any examples of how it would be done using c++ iostreams.

Can someone point me toward a book, article, or example?

TIA


There is absolutely no standard, portable way of doing this. C++ does
not provide or support keystrokes, all I/O is abstracted into
iostreams or FILE * streams. And in almost every operating system
today, you can start your program from a shell and make sure that its
standard input stream comes from a file or another device and has no
connection at all to a keyboard, assuming the system has one.

You need to ask in a group that specifically supports your compiler/OS
combination to see what sort of platform-specific non-standard
extensions it provides to do this.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Sep 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lampa Dario | last post by:
Hi, I need to estract single characters in a string, that may be '0' or '1', and evaluate them. I defined these variables char *binary; char cypher; int value;
2
by: Becker | last post by:
I have a two page TIFF document. I simply want to create an array of image and put the two pages of this multipage tiff in this array for some further processing on seperate "images." The...
2
by: Peteroid | last post by:
The following code: char x_char = '0' ; String^ x_str = c_char.ToString( ) ; results in: x_str = = "48" and not:
6
by: Ben | last post by:
Hi We have a Dataset that has been populated from the output parameter of a Stored Procedure (@Output). I understand that I can extract a single item when the dataset is populated by a table...
5
by: Zytan | last post by:
I am surprised that a single character string is not auto-created from a single char. It is hard to find information on converting a char into a string, since most people ask how to convert char...
4
by: mike | last post by:
guys, I've researched python pretty much but still have no idea how to print out each single character from a string in HEX format? Hope someone can give me some hints. Thanks a lot. e.g. ...
6
by: meisterbartsch | last post by:
Hi NG, I have got a starting pointer of a char series (mxArrayToString(pa)). I also know the length (number of elements by mxGetNumberOfElements) I want to read. How do I get a Cstring from...
2
by: Oki | last post by:
I appreciate any help; I'm currently getting a problem with trying to concatenate a single char from a structure to an existing string. Basically, the problem is here: strcat( res, morse_c.letter...
5
by: BOMEz | last post by:
I'm loading a series of descriptions and categories from a text file. I then load the descriptions into a drop down list. It works all fine when I first load the page, but then I submit some...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.