Press "esc" to stop asking for values

Hi i'm new here.

I want to make a c++ program that will ask values that can be stored in an array and when the user press "esc" the program will stop asking for the values and the program will identify the largest and smallest value stored in the said array.

I'm using windows.


Help me please.
Last edited on
Hello DracoL1ch,

The first thing you need to do is help your-self by mentioning what operating system you are using and what IDE yo arr using.


There is no point to getting suggestions that only work for Windows if you are using something else.

Andy
esc key can be tricky to trap. its doable, but its not as easy as pressing 'x'. does it HAVE to be esc?
If this is windows, then you need to use _getch() from #include <conio.h> which is non-standard. This obtains the entered char without also requiring a following \n.

Standard C++ has no mechanism to obtain a single char without a \n being also entered.

I'm using windows. This is a part of my exam and I don't know how to make this one, I'm Blank for this one. Thank you for all of your reply. I will explore more the Dev C++. Btw. I'm not a computer programmer that's why it's hard for me.
@jonnin
Yes sir, it has to be an esc that's why I'm having trouble with it.
For Windows, _getch() will get one char entered from the keyboard. The value for ESC is the decimal 27. See https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getch-getwch?view=msvc-160
For some reason I was thinking escape emitted 2 characters instead of just a 27 and was thinking to use the 'keypress'/ virtual keys tools on it which is more aggravation. Thankfully looks like 27 is good to go.
Topic archived. No new replies allowed.