473,385 Members | 1,528 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,385 software developers and data experts.

Reading a single character without waiting for enter key.

Hello Everybody,

I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?

Thanks for the help and time.

Warm Regards
:-) Johnsy
Nov 14 '05 #1
5 7700
Johnsy Joseph wrote:
Hello Everybody,

I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?
This is Question 19.1 in the comp.lang.c Frequently
Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html
Thanks for the help and time.


You'd be more welcome if you had read the FAQ first.
Hint, hint.

--
Er*********@sun.com

Nov 14 '05 #2


Johnsy Joseph wrote:
Hello Everybody,

I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?


Review faq question 19.1 for an explanation and possible solution.
19.1 is located at:

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

--
Al Bowers
Tampa, Fl USA
mailto: xa******@myrapidsys.com (remove the x to send email)
http://www.geocities.com/abowers822/

Nov 14 '05 #3
jo*************@hotmail.com (Johnsy Joseph) writes:
I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?


The C FAQ is at <http://www.eskimo.com/~scs/C-faq/faq.html>.
See question 19.1.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #4
Johnsy Joseph <jo*************@hotmail.com> scribbled the following:
Hello Everybody, I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?


C *does* read characters without waiting. It's your operating system
that waits for Enter. Unfortunately, there is no standard way to make
it stop waiting.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"That's no raisin - it's an ALIEN!"
- Tourist in MTV's Oddities
Nov 14 '05 #5
On Tue, 14 Dec 2004 20:45:02 +0000, Joona I Palaste wrote:
Johnsy Joseph <jo*************@hotmail.com> scribbled the following:
Hello Everybody,
I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?


C *does* read characters without waiting. It's your operating system
that waits for Enter.


While true at some level, the C standard makes no distinction between "C"
and an "operating system", they are both parts of and contribute to the
implementation. If the OS does something that is incompatible with the C
standard then it is the responsibility of the C package to make
appropriate adjustments/translations to provide a correct environment for
the program to run in. An example is text streams on an OS that
standardises something other than newline terminated lines.

The issue here is that blocking behaviour on input is NOT inconsistent
with the C standard, which makes no requirements about when a read
operation should complete. If it were inconsistent then the C package
would have to deal with the problem.
Unfortunately, there is no standard way to make
it stop waiting.


True, because the language designers chose not to address the issue, but
they could have.

Lawrence
Nov 14 '05 #6

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

Similar topics

9
by: JuanK | last post by:
hello, i'm trying to read a character from console just like getc function in c languaje i'm trying with WINAPI but dont works at this time.. other methods like clear screen works OK with the...
2
by: Jesper | last post by:
Hi, Is there a way to send a http message without waiting for the reply. I just want a server to register some information if its up and running. thanks Jesper.
3
by: JM | last post by:
Newbie Question Is there a way to use Message.Show so that it will allow the program to continue processing without waiting for a user to click OK?
7
by: gerry | last post by:
I have a com object that is used via an interop assembly - ie. I referenced the com object and vs.net created the interop .dll for it. I create one object per session when the page 1st loads and...
6
by: | last post by:
How do I convert a single character, e.g. "a" into char for use in the 'split' command? p.s. I have option strict on Tia.
5
by: Martin Kulas | last post by:
Hello! How do I replace a single character in a string at a given position? From programming languages like C I expect something like that: Traceback (most recent call last): File...
1
by: Siegfried Heintze | last post by:
Consider this program: Module Hello Declare Function _getch Lib "msvcrt.dll" () As Integer Dim out As System.IO.TextWriter = System.Console.Out Sub Main(args() as String) out.WriteLine("Hello...
8
by: Bill H | last post by:
In a php script I am using I need to call an external program and have it start running, but I don't want the php script to wait for it to finish. Looking at exec() and system() these would all...
9
by: erikcw | last post by:
Hi, I have a cgi script where users are uploading large files for processing. I want to launch a subprocess to process the file so the user doesn't have to wait for the page to load. What is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.