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

how to exit using ENTER KEY/CARRIAGE RETURN ???

Hey there:

I am done writing a rather large program for school and the only thing that is still driving me nuts is how to exit the program based on the fact that the return/carriage key was pressed. All input is stored as characters in an array... something like this:

char input1[9];
cout << "Enter number 1 (0-99999999):";
cin >> input1;

At this point I need to be able to determine if the user simply hits the ENTER KEY/CARRIAGE RETURN. I would appreciate any help I can possibly get because I have spent hours on this and tried ' ', '\n', and anything else I could think of....

Thank you very much!

Stefan
Oct 16 '06 #1
1 5163
Read each charactes instead of reading set of characters

while(1)
{
int ch=0;
cout << "Enter number 1 (0-99999999):";
ch = getche();
if(ch == 13 || ch == 26)//ENTER KEY/CARRIAGE RETURN
{
break;
}
}
Oct 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: PEACEMAKER | last post by:
I want to take an action when the user hits the enter key on a single line edit on the form but I can't find any events that handle the enter key. The char and keyup events still cause a beep on...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
3
by: Micus | last post by:
Greetings, I need to execute 2 applications from an application or batch file. The first app launched has the user enter a product key and the app's exit code will be 0 (failed) or 1...
1
by: samuelberthelot | last post by:
Hi, This is driving me crazy. In the following code, with e==68 (ASCII code for 'D'), the button is given the focus and the click is trigered :) However, if I change to e==13 (ASCII code for...
13
by: MZaza | last post by:
What command can I use to make the program quite after a certain condition? -- Mustafa Zaza
3
by: stevewy | last post by:
If the following line will force the user to input only a number between 1 and 5, and will give an error to any keypress outside that range: onkeyup="if(event.srcElement.value.search(new...
11
by: icarus | last post by:
Hi, this is a simple temperature converter (Fahrenheit to Celsius to Kelvin). Using gcc 4.0. The user is supposed to enter q or any other non-character to exit the program. Problem with this...
13
by: AliRezaGoogle | last post by:
Dear Members, I have a problem in the concepts of Monit.Enter and Monitor.Exit (Before everything I should say that I know how to solve this problem by using Monitor.Wait and I do not need a...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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
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,...
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...

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.