By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,619 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

Exit

P: n/a
HI

How would i go about implimenting a bit of code that will exit the
program upon the pressing of any key, and also for that of a predefined key.

Dan

Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Danny" <da***********@ntlworld.com> wrote...
How would i go about implimenting a bit of code that will exit the
program upon the pressing of any key, and also for that of a predefined

key.

FAQ 15.17, I believe, should be the one you need. You can find
FAQ list here: http://www.parashift.com/c++-faq-lite/

Victor
Jul 19 '05 #2

P: n/a
It doesn't appear to tell me how i can exit a program by entering a
specific key or any key

Victor Bazarov wrote:
"Danny" <da***********@ntlworld.com> wrote...
How would i go about implimenting a bit of code that will exit the
program upon the pressing of any key, and also for that of a predefined


key.

FAQ 15.17, I believe, should be the one you need. You can find
FAQ list here: http://www.parashift.com/c++-faq-lite/

Victor


Jul 19 '05 #3

P: n/a
"Danny" <da***********@ntlworld.com> wrote...
It doesn't appear to tell me how i can exit a program by entering a
specific key or any key
No, it doesn't. But it should be apparent that since you cannot
enter "any key", there is no way to do anything, exiting included.

If you find a way to enter a key, use "exit" function to exit the
program. RTFM.

Victor Bazarov wrote:
"Danny" <da***********@ntlworld.com> wrote...
How would i go about implimenting a bit of code that will exit the
program upon the pressing of any key, and also for that of a predefined


key.

FAQ 15.17, I believe, should be the one you need. You can find
FAQ list here: http://www.parashift.com/c++-faq-lite/

Victor

Jul 19 '05 #4

P: n/a
Danny wrote:
It doesn't appear to tell me how i can exit a program by entering a
specific key or any key


Please don't top-post. Re-read section 5 of the FAQ for posting guidelines.

Sometimes the answer to a question of the form "How can I do X" is "You
can't."

-Kevin

Jul 19 '05 #5

P: n/a
Danny wrote:
It doesn't appear to tell me how i can exit a program by entering a
specific key or any key


The C/C++ programming languages do not provide built in support for
keyboard / keypad devices of any kind. So there is no "standard C/C++"
answer to how one interacts with keyboard/keypad devices (e.g., how to
perform nonblocking input with a QWERTY keyboard made by company X,
whose model number is Y, and which is attached to a brand K computer
that is running operating system Z).

HOWEVER: Platform-specific tasks can performed by a C/C++ program *iff*
the C/C++ program uses platform-specific programming tools -- e.g.,
system services that the operating system's "application program
interface" (API) makes available to all programs (not just C/C++
programs); custom libraries that are designed specifically for the
OS/hardware environment you are using, etc. For example, the Win32
console API provides Windows apps (not just C/C++ apps) with a set of
keyboard, mouse, and display primitives that Windows programmers can use
in their Win32 console applications (e.g., to detect key presses; to
capture mouse events; to manipulate the console display, etc.). The
Win32 app simply calls the appropriate Win32 API function, and then the
Win32 API carries out the "request" on the program's behalf. (Note that
the Win32 API is part of the Windows OS itself.) In the Linux world,
C/C++ programmers can use the custom 'ncurses' library to perform
Linux-specific console I/O tasks.

Since these platform-specific solutions are not features of the C/C++
languages proper, there are no "standard C/C++" answers to how they are
used. (IOW, the people/companies who create these platform-specific
tools also specify how the tools must be used.) To learn more about
platform-specific programming solutions, visit the newsgroups and/or
mailing lists that are dedicated to programming issues for the
particular platform you are working with -- e.g., the Linux programming
newsgroups; the MacOS programming newsgroups; the Windows programming
newsgroups; the PalmOS programming newsgroups, etc. The folks in those
groups should be able to help you with platform-specific programming
tasks that do not have "standard C/C++" answers.

--
Jim

To reply by email, remove "link" and change "now.here" to "yahoo"
jfischer_link5809{at}now.here.com
Jul 19 '05 #6

P: n/a
If you are using win32 compiler you can check this:

http://www.codeproject.com/system/chotkeyhandler.asp

regards,
Elias
"Danny" <da***********@ntlworld.com> wrote in message
news:3F**************@ntlworld.com...
HI

How would i go about implimenting a bit of code that will exit the
program upon the pressing of any key, and also for that of a predefined key.
Dan

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.