Dear all,
I would like to ask if there is any C function that accept one
keystroke as input, without printing out what the user presses
and without the need to press enter as delimiter. getchar()
can accept a character, but it needs user to press enter to
accept the input.
Thanks very much.
Regards,
LaBird (Benny). 6 15755
In article <bm**********@www.csis.hku.hk>, LaBird wrote: Dear all,
I would like to ask if there is any C function that accept one keystroke as input, without printing out what the user presses and without the need to press enter as delimiter. getchar() can accept a character, but it needs user to press enter to accept the input.
There is no such function in C. Please read the FAQ at http://www.eskimo.com/~scs/C-faq/q19.1.html
--
Andreas Kähäri
Andreas Kahari <ak*******@freeshell.org> scribbled the following: In article <bm**********@www.csis.hku.hk>, LaBird wrote: Dear all,
I would like to ask if there is any C function that accept one keystroke as input, without printing out what the user presses and without the need to press enter as delimiter. getchar() can accept a character, but it needs user to press enter to accept the input.
There is no such function in C. Please read the FAQ at
http://www.eskimo.com/~scs/C-faq/q19.1.html
It's not that easy to answer. It actually depends on your OS settings.
It is fully possible that getchar() can receive characters as you type
them from the keyboard. The point is that getchar() receives characters
as they appear in stdin. But the connection between stdin and the
keyboard is none of C's business.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A computer program does what you tell it to do, not what you want it to do."
- Anon
In article <bm**********@oravannahka.helsinki.fi>, Joona I Palaste wrote: Andreas Kahari <ak*******@freeshell.org> scribbled the following:
[cut] There is no such function in C. Please read the FAQ at
http://www.eskimo.com/~scs/C-faq/q19.1.html
It's not that easy to answer. It actually depends on your OS settings. It is fully possible that getchar() can receive characters as you type them from the keyboard. The point is that getchar() receives characters as they appear in stdin. But the connection between stdin and the keyboard is none of C's business.
Do you by "settings" mean "buffered or unbuffered"?
I believe that's what the parenthasis at the end addresses:
(As an aside, note that simply using setbuf or setvbuf to
set stdin to unbuffered will not generally serve to allow
character-at-a-time input.)
--
Andreas Kähäri
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bm**********@oravannahka.helsinki.fi... Andreas Kahari <ak*******@freeshell.org> scribbled the following: In article <bm**********@www.csis.hku.hk>, LaBird wrote: Dear all,
I would like to ask if there is any C function that accept one keystroke as input, without printing out what the user presses and without the need to press enter as delimiter. getchar() can accept a character, but it needs user to press enter to accept the input.
There is no such function in C. Please read the FAQ at
http://www.eskimo.com/~scs/C-faq/q19.1.html
It's not that easy to answer. It actually depends on your OS settings. It is fully possible that getchar() can receive characters as you type them from the keyboard. The point is that getchar() receives characters as they appear in stdin. But the connection between stdin and the keyboard is none of C's business.
In other words, you can do it in C using OS-specific library calls
which are off-topic here. You need to ask in a newsgroup specific
to the OS and/or compiler you are using. Maybe comp.unix.programmer
or ... well, one of the others.
Or, as Joona Palaste says, you can use standard C functions *after*
using OS-specific commands to put your system into the appropriate
state. Again, these are off-topic here and you should ask in
an OS-specific newsgroup.
John.
Dear Andreas,
Thanks a lot. I am programming in Linux. According to your guide,
now I can search from the web for the exact functions specific to
Linux that serves what I wanted.
Regards,
LaBird (Benny).
"Andreas Kahari" <ak*******@freeshell.org> wrote in message
news:sl**********************@mx.freeshell.org... In article <bm**********@www.csis.hku.hk>, LaBird wrote: Dear all,
I would like to ask if there is any C function that accept one keystroke as input, without printing out what the user presses and without the need to press enter as delimiter. getchar() can accept a character, but it needs user to press enter to accept the input.
There is no such function in C. Please read the FAQ at
http://www.eskimo.com/~scs/C-faq/q19.1.html -- Andreas Kähäri
Andreas Kahari <ak*******@freeshell.org> scribbled the following: In article <bm**********@oravannahka.helsinki.fi>, Joona I Palaste wrote: Andreas Kahari <ak*******@freeshell.org> scribbled the following: [cut] There is no such function in C. Please read the FAQ at
http://www.eskimo.com/~scs/C-faq/q19.1.html
It's not that easy to answer. It actually depends on your OS settings. It is fully possible that getchar() can receive characters as you type them from the keyboard. The point is that getchar() receives characters as they appear in stdin. But the connection between stdin and the keyboard is none of C's business.
Do you by "settings" mean "buffered or unbuffered"?
I believe that's what the parenthasis at the end addresses:
(As an aside, note that simply using setbuf or setvbuf to set stdin to unbuffered will not generally serve to allow character-at-a-time input.)
No, I mean different settings than setbuf or setvbuf. I mean settings
that affect the OS level, which goes deeper than stdin.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I am looking for myself. Have you seen me somewhere?"
- Anon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: paul |
last post by:
Have read the FAQ's and the forums but still cant find a good solution
to this. I am using Linux and G++. I am trying to run a program which
computes something or other and have the ability to...
|
by: Steve Wylie |
last post by:
At work we use SNAP survey software. The software is capable of
outputting a survey as a web page, in HTML, which we can tart up with
Javascript for basic form validation if required. When the...
|
by: Andrew Parish |
last post by:
I have a page with an input text box and a button which validates the
text (see below). If I click inside the text box, the button is
highlighted. If I enter some text inside the box and press...
|
by: mg |
last post by:
I want to enter characters in a TextBox in a WebForm,
press a Button in the WebForm, and read the characters
that were typed into the TextBox from within the
Button_Click event handler. The main...
|
by: peshrad |
last post by:
Hi !
I'm working with Win 2K and Visual Studio 2003.
I have a problem because pressing <ENTER> in a text input control causes a
postback of my web form.
Here comes some example code (already...
|
by: Hulo |
last post by:
In a C program I am required to enter three numbers (integers) e.g. 256
7 5 on execution of the program.
C:\> 256 7 5
There should be spaces between the three numbers and on pressing
"enter",...
|
by: unni.tallman |
last post by:
how can i read input from stdin, char by char, i want to get the
character as soon as it is entered, without having to press 'Enter'
after each character.
|
by: Newbie |
last post by:
Hello I need to enter a string of the form abc (a string of
characters followed by EOF)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
int main(void)
{
|
by: jd |
last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key
when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
|
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
|
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,...
|
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...
|
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,...
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |