473,748 Members | 3,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wait for keyboard entry ?

Hi everybody,

It's me again...Pelo, for an other beginner question...

What the code should be in C++ to wait for a keyboard entry in order to
execute the sequal of my program...


Jul 22 '05 #1
11 18248
I found by myself...

#include <conio.h>
cout << "Press any key to terminate this program. " ; getch();

The getch() function call causes the program to wait for a single keystroke.

"Pelo GANDO" <o0****@hotmail .com> a écrit dans le message de news:
c2**********@ne ws-reader3.wanadoo .fr...
Hi everybody,

It's me again...Pelo, for an other beginner question...

What the code should be in C++ to wait for a keyboard entry in order to
execute the sequal of my program...

Jul 22 '05 #2
"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader5.wanadoo .fr...
I found by myself...

#include <conio.h>
cout << "Press any key to terminate this program. " ; getch();

The getch() function call causes the program to wait for a single

keystroke.

But alas it's not part of the C++ language. It's an
'extension' provided by your implementation, not topical
here. Here we discuss the ISO standard C++ langauge, which
has no means to do what you're asking.

See:
http://www.slack.net/~shiva/welcome.txt

-Mike

Jul 22 '05 #3
thank you !
"Mike Wahler" <mk******@mkwah ler.net> a écrit dans le message de news:
5X************* *****@newsread1 .news.pas.earth link.net...
"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader5.wanadoo .fr...
I found by myself...

#include <conio.h>
cout << "Press any key to terminate this program. " ; getch();

The getch() function call causes the program to wait for a single

keystroke.

But alas it's not part of the C++ language. It's an
'extension' provided by your implementation, not topical
here. Here we discuss the ISO standard C++ langauge, which
has no means to do what you're asking.

See:
http://www.slack.net/~shiva/welcome.txt

-Mike

Jul 22 '05 #4
Sir,
How would you do in ISO standard C++...
I would like knwo from you...

Thank you

"Mike Wahler" <mk******@mkwah ler.net> a écrit dans le message de news:
5X************* *****@newsread1 .news.pas.earth link.net...
"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader5.wanadoo .fr...
I found by myself...

#include <conio.h>
cout << "Press any key to terminate this program. " ; getch();

The getch() function call causes the program to wait for a single

keystroke.

But alas it's not part of the C++ language. It's an
'extension' provided by your implementation, not topical
here. Here we discuss the ISO standard C++ langauge, which
has no means to do what you're asking.

See:
http://www.slack.net/~shiva/welcome.txt

-Mike

Jul 22 '05 #5

"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader3.wanadoo .fr...
Hi everybody,

It's me again...Pelo, for an other beginner question...

What the code should be in C++ to wait for a keyboard entry in order to
execute the sequal of my program...


c++ doesn't have such a concept.

If you work under character environments such as unix or old dos you'll
usually call a single function to achieve that. Non standard headers like
<conio.h> for dos may provide what you're looking for. Others will point you
to correct newsgroups.

If you work under some GUI like Windows or the X, than your whole program
concept changes. You wait for specific messages/callbacks from your
OS/GUI/Framework manager or whatever. And that's a complex topic which is
not discussed here.
Jul 22 '05 #6
"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader2.wanadoo .fr...
Sir,
How would you do
[nonblocking input]
in ISO standard C++...
I would like knwo from you...


Like I said, it cannot be done with standard C++.
You'll need to use an extension, such as the
one you mentioned. However you should note
that this will only work with that particular
compiler, others will have their own way, if
they have any at all. When you encounter this
situation, I advise you to isolate and clearly
identify such uses, so porting will be easier
when the time comes.

-Mike
Jul 22 '05 #7
> What the code should be in C++ to wait for a keyboard entry in order to
execute the sequal of my program...


You can use std::cin which redirects input from stdin (your keyboard) to a
string in your program. Example

#include <string>

int main()
{
std::string sInputString;
// Wait for input from stdin (the keyboard)
std::cin >> sInputString;

// Print out to the screen what the user just input
std::cout << "The user just input the following string: " <<
sInputString << std::endl;
}

I hope this helps

Jul 22 '05 #8
What is wrong with
std::cin >> SomeString;

Jacob

"Mike Wahler" <mk******@mkwah ler.net> wrote in message
news:7k******** ***********@new sread1.news.pas .earthlink.net. ..
"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader2.wanadoo .fr...
Sir,
How would you do


[nonblocking input]
in ISO standard C++...
I would like knwo from you...


Like I said, it cannot be done with standard C++.
You'll need to use an extension, such as the
one you mentioned. However you should note
that this will only work with that particular
compiler, others will have their own way, if
they have any at all. When you encounter this
situation, I advise you to isolate and clearly
identify such uses, so porting will be easier
when the time comes.

-Mike

Jul 22 '05 #9
Mike Wahler wrote:
"Pelo GANDO" <o0****@hotmail .com> wrote in message
news:c2******** **@news-reader2.wanadoo .fr...
Sir,
How would you do


[nonblocking input]


How would waiting for keyboard input be _non_blocking?

Jul 22 '05 #10

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

Similar topics

3
3152
by: Ziv Forshtat | last post by:
Hi All, I'm in the process of implementing a virtual keypad: I have a wxFrame which contains a photo the keypad of some device, and I'm using it to enter special keywords into an editor window (wxStc). Each part of the photo is associated with a certain keyword, which is sent to the editor frame and displayed inside the editor. This is working fine. However, if I want a proper virtual keyboard I should also be able to transfer the regular...
3
4646
by: Tomasz \Boruh\ Borowiak | last post by:
Does anybody have any idea how to write a c++ console application which simulates the mobile phone keyboard ? for Example: when i write SMS I hit 2 - I get "a" I hit 22 - I get "b" I hit 222 - I get "C"; Please help. thanks for all replays boruh
0
1784
by: David G. | last post by:
The keyboard type ahead buffer does not seem to work in Access 2003 in certain situations. We would like some help with this. Here are the details. We have a large program that was developed in Access 2000. We are now converting it to Access 2003. The program has a form for entering orders. Each order usually consists of dozens of items. To enter the items on the order the entry person
1
2107
by: Rob T | last post by:
I'm porting over an application that runs on an AS/400 over to asp.net. One of the features my users like is to be able to start typing before the screen is loaded. (this is a 5250 emulator, not IE). In some cases they are able to pass through several screens before they even load. For example, in an order entry screen, they could go past the 'customer name' screen, then 'shipping info' screen, then 'billing info' screen to end up at...
7
2781
by: sparks | last post by:
When you enter an option group you can move to each option with the arrow keys and select with the space bar. Option groups don't have keydown events so has anyone come up with a way to allow keyboard entry for option groups? Just a simple way to select with 1-5 from the keypad or some such. thanks for any help or a link to what to read.
0
1930
by: luc.saffre | last post by:
Hello, I thought that I should ask here for comments on a blog entry that I wrote some weeks ago. I am sure that other people have been thinking about this, but I didn't yet find them. The Python standard library unfortunately doesn't provide a module that gives unique names to common keyboard events. Even Tkinter had to write a complex parser to find out which keyboard
0
1264
by: EgoSum | last post by:
Can someone help me with custom text box? I want change behavior custom date text box - disallow entry and pass entry from numeric keyboard to a text box. Code below disallow entry, but how I can pass entry? public class myDateTextBox : AMS.TextBox.DateTextBox { protected override bool ProcessDialogKey(Keys keyData) {if (keyData >= Keys.NumPad0 && keyData <= Keys.NumPad9) {base.ProcessDialogKey(keyData); return true;
2
1903
by: EgoSum | last post by:
Can someone help me with custom text box? I want change behavior custom date text box - disallow entry and pass entry from numeric keyboard to a text box. Code below disallow entry, but how I can pass entry? public class myDateTextBox : AMS.TextBox.DateTextBox { protected override bool ProcessDialogKey(Keys keyData) {if (keyData >= Keys.NumPad0 && keyData <= Keys.NumPad9) { return true;
1
1158
by: Jamie21Cor | last post by:
Hi I have just recently started programming in c#, lm creating a program that shows a window if specified keys are pressed, but while the window is not showing the form keyPressed event cannot be viewed. I was wondering if there was any way to detect the keyboard actions while the program form is hidden. Can anyone help with this?
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.