how to quit

Discussion in 'C Programming' started by Thomas, Mar 29, 2007.

  1. Thomas

    Thomas Guest

    Hi,
    Thanks to those who replied to my question.
    Well the actual thing is when i make a program in C,user can only exit
    from it when that particular code lie is executed.
    In that line i use any suitable input function then i compare it using
    if function. there if condition is true, it exits otherwise not.
    Now i want this capability that user doesn't have to wait for that
    particular line to be executed.
    Whenever he presses a particular key, lets say Q, my program picks it,
    compares and exit.
    I mean that such function would be running in the background
    simultaneously with other functions or lines of my program.
    Is it possible and how?
     
    Thomas, Mar 29, 2007
    #1
    1. Advertising

  2. Thomas

    Bill Pursell Guest

    On 29 Mar, 04:56, "Thomas" <> wrote:

    > Well the actual thing is when i make a program in C,user can only exit
    > from it when that particular code lie is executed.
    > In that line i use any suitable input function then i compare it using
    > if function. there if condition is true, it exits otherwise not.
    > Now i want this capability that user doesn't have to wait for that
    > particular line to be executed.
    > Whenever he presses a particular key, lets say Q, my program picks it,
    > compares and exit.
    > I mean that such function would be running in the background
    > simultaneously with other functions or lines of my program.
    > Is it possible and how?


    It is possible, but the mechanism to accomplish it will
    depend on the system you are using and it cannot be
    done portably. You must use things that are outside of
    the C language itself. (eg [n]curses and/or threads.)
    You will get better responses if you post your question
    to a group dedicated to the system on which you are
    trying to accomplish this task. Although, as has
    been mentioned, you might find it easier to use the
    mechanism provided by your system for terminating
    you process. For example, on most (probably all)
    unix-like systems, ctrl-C (or some other keystroke)
    will send a signal to the foreground process (your
    program). By default, your program will terminate
    when it receives that signal, but you can catch
    the signal and take other actions if you wish. However,
    that is outside the scope of the language itself, and
    you should really take the question to a system specific
    news group.

    --
    Bill Pursell
     
    Bill Pursell, Mar 29, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M. Duijkers
    Replies:
    2
    Views:
    483
    Joe Smith
    Dec 12, 2004
  2. Craig

    Postback quit working

    Craig, Sep 27, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    674
    Kikoz
    Sep 27, 2004
  3. GD
    Replies:
    2
    Views:
    371
  4. =?Utf-8?B?RXpoaWw=?=

    Could not quit MSACCESS.EXE

    =?Utf-8?B?RXpoaWw=?=, Dec 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    497
    Ken Cox [Microsoft MVP]
    Dec 27, 2004
  5. metfan
    Replies:
    9
    Views:
    472
    Mark Thornton
    Nov 2, 2003
Loading...

Share This Page