473,651 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting keyboard input in C

Hey all,

Is there a function already within ANSI C that waits for character input
until a key is pressed? I know getchar() but, of course, even that waits
for a carriage return before the code moves on...
Thanks

Dave
Nov 14 '05 #1
2 13429
Dave wrote:
Hey all,

Is there a function already within ANSI C that waits for character input
until a key is pressed? I know getchar() but, of course, even that waits
for a carriage return before the code moves on...


No.

Please read the FAQ, at:

http://www.eskimo.com/~scs/C-faq/top.html

HTH,
-ag
--
Artie Gold -- Austin, Texas

Nov 14 '05 #2
On Sun, 18 Jan 2004 17:53:57 +0000, Dave <dm*****@nospam .com> wrote::
Hey all,

Is there a function already within ANSI C that waits for character input
until a key is pressed? I know getchar() but, of course, even that waits
for a carriage return before the code moves on...
Thanks

Dave


No. Not in ANSI or ISO C. If you're looking for something to deal
with the old "Press the any key" type situation, you'll have to step
outside of ANSI or ISO C.

On winDOS platforms, *most* compilers have these functions in the
*non-standard* conio.h header. *most*, because some compilers won't
have it at all, and some will have it as a part of some other header.

getch();

or

getche(); // if you want to echo the keypress' character equivalent
// to stdout

If you want something more portable, ncurses has similar functions
(also similarly named). Of course, you still wouldn't be dealing
strictly with standard C, as you'd be using an external library.
----------------------------------------
Thanks,
MCheu
Nov 14 '05 #3

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

Similar topics

0
2001
by: Ray | last post by:
I have English Windows XP Pro and Office 2003 Pro on my computer. When I enter data into fields of tables, queries and forms of Access 2003, it automatically switches to Chinese keyboard input. Even though I remove the Chinese keyboard input from Regional applet, the system will automatically reinstall Chinese keyboard input when I enter data in Office 2003. After I switch from Chinese keyboard input back to English keyboard input, it...
23
7724
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard buffer ? are they same ? thanks ^^
4
3869
by: santa19992000 | last post by:
can I use scanf to get input (some times user enters input sometimes not, just hit keyboard)?. It displays to enter IP address, if user wants to change, then he enters, otherwise he hits keyboard, which should prompt next one, how can I do in C program?. Thanks. enter IP address:
7
10634
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it were a keyboard. I need to be able to identify input from the scanner and keyboard independently. I've looked at DirectX.DirectInput, and using user32.dll to hook into the keyboard messages, but neither method seems to allow for identification of...
7
26532
by: jpierson | last post by:
Hi, I am tryin to create a keyboard hook that sends the keystroke ctrl + pause/break. I haven't used keyboard hooks before so I'm not too sure how to use them public int MyKeyboardProc(int nCode, int wParam, int lParam) {
1
6814
by: Louis Cypher | last post by:
I'm working on an application (OEM) using c# that uses input from a keyboard and a USB Barcode Scanner. I need to be able to identify keystrokes from the barcode scanner and remove them from the message queue, regardless of what application has focus. I can identify the keystrokes and input device by registering for raw input (RegisterRawInputDevices) and processing the WM_INPUT message. This gives me the keystrokes and the ability to...
1
2530
by: biznitchil | last post by:
it is a bit jacked up, but copy and paste it into an IDE(i use jGRASP) plz help me...it worked just fine before I added the menu..you can e-mail me if you have any <Removed> import java.util.*; public class VowelsConsCounter { public int i= list.indexOf(object); public static char getMenuSelection(); { String input; char selection; Scanner keyboard = new Scanner(System.in);
4
20213
by: Gerry19 | last post by:
Hi All, I'm trying to monitor data passed from a USB Barcode scanner but I can't find any decent code examples of what I need to do, including any references I need to include. I know I need to use RegisterRawInputDevices & WM_INPUT but have no idea where to start. Any help greatly appreciated.
3
2997
by: NaN | last post by:
I've been trying to use _kbhit() but it didn't do what I thought it would from books, "Detects whether a keypress is available for reading." Herbert Schildt says, "If the user has pressed a key, this function returns true(non-0), but does not read the character. If no keystroke is pending, kbhit() returns false (0)." Here is the test code,
8
5293
by: BD | last post by:
How can I duplicate the behavior of the operating system shortcut keys in my application? For example, my windows form has 5 controls (textboxes), the operating system will pickup which control has the focus and handle ctrl-c, ctrl-v, or any other shortcuts. I have the same shortcuts working in my app, but have not determined how to find out which control has focus. Would I set up a loop or code for each control at form level. Any help...
0
8352
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
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8697
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
8465
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
8579
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
6158
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
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2699
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
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.