471,047 Members | 1,222 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,047 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!

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

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

Post your reply

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

Similar topics

1 post views Thread by samuelberthelot | last post: by
13 posts views Thread by MZaza | last post: by
5 posts views Thread by lemlimlee | last post: by

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.