how to quit

Discussion in 'C Programming' started by mynameisthomasanderson@gmail.com, Mar 28, 2007.

  1. Guest

    Hi,
    I'm pretty new to programming and i need a bit help from you, the
    experienced programmers.
    Well the thing is I'm making a small program on C. I want that
    whenever user presses the key combination of ctrl+F3, he exits from
    the program. how could I code this thing?
     
    , Mar 28, 2007
    #1
    1. Advertising

  2. Daniel Rudy Guest

    At about the time of 3/27/2007 9:29 PM,
    stated the following:
    > Hi,
    > I'm pretty new to programming and i need a bit help from you, the
    > experienced programmers.
    > Well the thing is I'm making a small program on C. I want that
    > whenever user presses the key combination of ctrl+F3, he exits from
    > the program. how could I code this thing?
    >


    Well, to exit, you do exit(EXIT_SUCCESS) or exit(EXIT_FAILURE). As for
    control key sequences, you will need to find out what characters are
    generated when a user hits CTRL-F3, then have your program look for that
    key sequence.


    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m

    Why geeks like computers: look chat date touch grep make unzip
    strip view finger mount fcsk more fcsk yes spray umount sleep
     
    Daniel Rudy, Mar 28, 2007
    #2
    1. Advertising

  3. CBFalconer Guest

    wrote:
    >
    > I'm pretty new to programming and i need a bit help from you, the
    > experienced programmers. Well the thing is I'm making a small
    > program on C. I want that whenever user presses the key combination
    > of ctrl+F3, he exits from the program. how could I code this thing?


    Probably easier to have him hit CTL-C. You will probably not have
    to do anything.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    CBFalconer, Mar 28, 2007
    #3
  4. user923005 Guest

    On Mar 27, 9:29 pm, wrote:
    > Hi,
    > I'm pretty new to programming and i need a bit help from you, the
    > experienced programmers.
    > Well the thing is I'm making a small program on C. I want that
    > whenever user presses the key combination of ctrl+F3, he exits from
    > the program. how could I code this thing?


    >From the C-FAQ:


    19.5: How do I read the arrow keys? What about function keys?

    A: Terminfo, some versions of termcap, and some versions of curses
    have support for these non-ASCII keys. Typically, a special key
    sends a multicharacter sequence (usually beginning with ESC,
    '\033'); parsing these can be tricky. (curses will do the
    parsing for you, if you call keypad() first.)

    Under MS-DOS, if you receive a character with value 0 (*not*
    '0'!) while reading the keyboard, it's a flag indicating that
    the next character read will be a code indicating a special key.
    See any DOS programming guide for lists of keyboard scan codes.
    (Very briefly: the up, left, right, and down arrow keys are 72,
    75, 77, and 80, and the function keys are 59 through 68.)

    References: PCS Sec. 5.1.4 pp. 56-7.
     
    user923005, Mar 28, 2007
    #4
  5. SM Ryan Guest

    wrote:
    # Hi,
    # I'm pretty new to programming and i need a bit help from you, the
    # experienced programmers.
    # Well the thing is I'm making a small program on C. I want that
    # whenever user presses the key combination of ctrl+F3, he exits from
    # the program. how could I code this thing?

    Whether you want to poll for keypress or arrange some kind of
    interrupt handler, you'll need a system specific function. What you're
    going to get from ANSI C by itself is to stop the program until
    input is available and then check the input characters. So it's going
    to depend on the operating system and/or the windowing system.

    --
    SM Ryan http://www.rawbw.com/~wyrmwif/
    I have no respect for people with no shopping agenda.
     
    SM Ryan, Mar 28, 2007
    #5
  6. user923005 <> wrote:
    > On Mar 27, 9:29 pm, wrote:
    >> Hi,
    >> I'm pretty new to programming and i need a bit help from you, the
    >> experienced programmers.
    >> Well the thing is I'm making a small program on C. I want that
    >> whenever user presses the key combination of ctrl+F3, he exits from
    >> the program. how could I code this thing?


    >>From the C-FAQ:


    > 19.5: How do I read the arrow keys? What about function keys?


    > A: Terminfo, some versions of termcap, and some versions of curses


    oh. "some versions of termcap" is a little odd (can anyone point
    to a version of termcap that does not?).

    most versions of curses as well - but this isn't the first inaccuracy
    we've seen in the FAQ.

    regards.

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Mar 28, 2007
    #6
  7. user923005 Guest

    On Mar 28, 9:01 am, Thomas Dickey <> wrote:
    > user923005 <> wrote:
    > > On Mar 27, 9:29 pm, wrote:
    > >> Hi,
    > >> I'm pretty new to programming and i need a bit help from you, the
    > >> experienced programmers.
    > >> Well the thing is I'm making a small program on C. I want that
    > >> whenever user presses the key combination of ctrl+F3, he exits from
    > >> the program. how could I code this thing?
    > >>From the C-FAQ:

    > > 19.5: How do I read the arrow keys? What about function keys?
    > > A: Terminfo, some versions of termcap, and some versions of curses

    >
    > oh. "some versions of termcap" is a little odd (can anyone point
    > to a version of termcap that does not?).
    >
    > most versions of curses as well - but this isn't the first inaccuracy
    > we've seen in the FAQ.


    If you have proof that there are no exceptions, then send an email to
    Steve and he will correct it, I imagine.
    I guess that there is at least one exception in either case.
    Of course, both statements are mathematically true, because 'some' is
    a subset of 'all'.
    In any case, it's a nit.
     
    user923005, Mar 28, 2007
    #7
  8. user923005 <> wrote:

    > If you have proof that there are no exceptions, then send an email to
    > Steve and he will correct it, I imagine.


    He said he would the last time I pointed out an error.
    He didn't correct it.

    > I guess that there is at least one exception in either case.
    > Of course, both statements are mathematically true, because 'some' is
    > a subset of 'all'.
    > In any case, it's a nit.


    hmm - no. It's incorrect, and (even given the old information that he
    used), was never correct since the FAQ was written.

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Mar 28, 2007
    #8
  9. Thomas Dickey, Mar 28, 2007
    #9
  10. In article <>,
    Thomas Dickey <> wrote:

    >>> If you have proof that there are no exceptions, then send an email to
    >>> Steve and he will correct it, I imagine.


    >btw, his copyright precludes any extensive discussion.
    >
    > http://c-faq.com/copyright.html


    How can copyright preclude discussion?

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Mar 28, 2007
    #10
  11. Richard Tobin <> wrote:
    > In article <>,
    > Thomas Dickey <> wrote:


    >>>> If you have proof that there are no exceptions, then send an email to
    >>>> Steve and he will correct it, I imagine.


    >>btw, his copyright precludes any extensive discussion.
    >>
    >> http://c-faq.com/copyright.html


    > How can copyright preclude discussion?


    Read the page (obviously you either did not, or the implication of
    extensive discussion was too elusive ;-).

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Mar 29, 2007
    #11
  12. Thomas Dickey <> writes:
    > user923005 <> wrote:
    >> If you have proof that there are no exceptions, then send an email to
    >> Steve and he will correct it, I imagine.

    >
    > He said he would the last time I pointed out an error.
    > He didn't correct it.

    [...]

    He is but human. Consider trying again.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 29, 2007
    #12
  13. In article <>,
    Keith Thompson <> wrote:
    >Thomas Dickey <> writes:
    >> user923005 <> wrote:
    >>> If you have proof that there are no exceptions, then send an email to
    >>> Steve and he will correct it, I imagine.

    >>
    >> He said he would the last time I pointed out an error.
    >> He didn't correct it.

    >[...]
    >
    >He is but human. Consider trying again.


    The implication is that this was not a one time occurrence.

    My reading of Thomas's text is that he has pointed out several errors
    over the years, and that, on at least one occasion, Steve explicitly
    said that it would be fixed, but nothing happened. Hence the loss of
    faith.
     
    Kenny McCormack, Mar 29, 2007
    #13
  14. Default User Guest

    Thomas Dickey wrote:

    > Richard Tobin <> wrote:
    > > In article <>,
    > > Thomas Dickey <> wrote:

    >
    > >>>> If you have proof that there are no exceptions, then send an

    > email to >>>> Steve and he will correct it, I imagine.
    >
    > > > btw, his copyright precludes any extensive discussion.
    > > >
    > > > http://c-faq.com/copyright.html

    >
    > > How can copyright preclude discussion?

    >
    > Read the page (obviously you either did not, or the implication of
    > extensive discussion was too elusive ;-).



    Yeah, so? Besides not seeing anything in there relevant to what you
    say, the copyright holder can't make it more restrictive than the law
    allows.




    Brian
     
    Default User, Mar 29, 2007
    #14
  15. Thomas Dickey <> writes:
    > Thomas Dickey <> wrote:
    >> user923005 <> wrote:

    >
    >>> If you have proof that there are no exceptions, then send an email to
    >>> Steve and he will correct it, I imagine.

    >
    > btw, his copyright precludes any extensive discussion.
    >
    > http://c-faq.com/copyright.html


    Here's what that page currently says (I'm going to assume that quoting
    it is covered under fair use):

    This collection of hypertext pages is Copyright 1995-2005 by Steve
    Summit. Content from the book "C Programming FAQs: Frequently
    Asked Questions" (Addison-Wesley, 1995, ISBN 0-201-84519-9) is
    made available here by permission of the author and the publisher
    as a service to the community. It is intended to complement the
    use of the published text and is protected by international
    copyright laws. The on-line content may be accessed freely for
    personal use but may not be published or retransmitted without
    explicit permission.

    I see nothing there that precludes discussion, unless you assume that
    discussion requires quoting substantial parts of the FAQ. Since the
    FAQ is well indexed, a great deal of discussion can take place using
    question numbers or hyperlinks.

    I Am Not A Lawyer.

    Re-posting the entire FAQ would fairly clearly be a copyright
    violation. Citing individual questions presumably would not. Quoting
    portions of it might or might not fall under fair use, depending on
    the size of the quotation and on other factors about which, not being
    a lawyer, I won't speculate.

    Steve has tended to be reasonably generous in allowing use of the FAQ,
    at least as generous as his publisher allows him to be. People have
    occasionally quoted entire pages here, with no complaint from Steve.
    (Personally, I prefer just to cite question numbers, not just to avoid
    copyright infringement, but because it encourages readers to browse
    nearby portions of the document.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 29, 2007
    #15
  16. Thomas Dickey wrote:
    >
    > user923005 <> wrote:
    >
    > > If you have proof that there are no exceptions, then send an email to
    > > Steve and he will correct it, I imagine.

    >
    > He said he would the last time I pointed out an error.
    > He didn't correct it.
    >
    > > I guess that there is at least one exception in either case.
    > > Of course, both statements are mathematically true, because 'some' is
    > > a subset of 'all'.
    > > In any case, it's a nit.

    >
    > hmm - no. It's incorrect, and (even given the old information that he
    > used), was never correct since the FAQ was written.


    I, presonally, have used versions of termcap that had no concept
    as "function keys" (ie: F1, F2, and so on). Of course, that was
    some 20 years ago, and the modern implementations that I have seen
    have entries for such keys. Whether any versions still exist that
    do not support them, I cannot say.

    --
    +-------------------------+--------------------+-----------------------+
    | Kenneth J. Brody | www.hvcomputer.com | #include |
    | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------+
    Don't e-mail me at: <mailto:>
     
    Kenneth Brody, Mar 29, 2007
    #16
  17. Kenneth Brody <> wrote:
    > Thomas Dickey wrote:
    >> hmm - no. It's incorrect, and (even given the old information that he
    >> used), was never correct since the FAQ was written.


    > I, presonally, have used versions of termcap that had no concept
    > as "function keys" (ie: F1, F2, and so on). Of course, that was
    > some 20 years ago, and the modern implementations that I have seen
    > have entries for such keys. Whether any versions still exist that
    > do not support them, I cannot say.


    hmm. termcap stores the whole entry as a string. Function keys and
    other capabilities are string-capabilities with conventional (not
    standardized) names. So any termcap file can represent function keys.

    That is, unless you were using some highly advanced technology which
    deduced that some capability names referred to function keys and
    prevented you from using them.

    If that's the case, you should elaborate on it.

    More likely, you simply did not know.

    termcap, when I first encountered it in the early 80's was certainly
    capable of representing function keys. It was taken for granted that
    termcap could represent anything that an application needed from a
    terminal.

    Curses did not necessarily have a parser for those (as I recall writing
    one in late 1983/early 1984 to make BSD 4.3's curses more palatable with
    a couple of terminals for some applications that used both cursor-keys
    and function-keys).

    Here's one -

    http://vt100.net/annarbor/aaa-ug/section4.html#S4.1

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Mar 29, 2007
    #17
  18. Thomas Dickey wrote:
    >
    > Kenneth Brody <> wrote:
    > > Thomas Dickey wrote:
    > >> hmm - no. It's incorrect, and (even given the old information that he
    > >> used), was never correct since the FAQ was written.

    >
    > > I, presonally, have used versions of termcap that had no concept
    > > as "function keys" (ie: F1, F2, and so on). Of course, that was
    > > some 20 years ago, and the modern implementations that I have seen
    > > have entries for such keys. Whether any versions still exist that
    > > do not support them, I cannot say.

    >
    > hmm. termcap stores the whole entry as a string. Function keys and
    > other capabilities are string-capabilities with conventional (not
    > standardized) names. So any termcap file can represent function keys.


    Okay, let me clarify...

    What I meant was that there were no standardized entries for such
    keys. So, unless you wanted to write custom termcap entries for
    every terminal you wanted to support, you were stuck with the
    standard, defined entries. Current versions appear to have
    defined a standard set of entries for these keys.

    On the other hand, current versions of termcap are often simply
    wrappers to terminfo routines, and terminfo is not extensible. If
    the entry wasn't defined by the implementor of the library, you
    cannot add it.

    Now, we defined our own entries for the functionality we wanted to
    support, and wrote a wrapper around the termcap routines that could
    use both the /etc/termcap file (or $TERMCAP), plus our application-
    specific termcap file stored elsewhere. This allowed us to simply
    enhance the existing termcap file, rather than replace it.

    Of course, all of this is OT for clc. On the other hand, writing
    a termcap library would probably be topical for clc, as you could
    implement it in ANSI C, AFAIK. After all, it's just some functions
    which read and parse a text file, and then use that info to send
    things to stdout.

    [...]

    --
    +-------------------------+--------------------+-----------------------+
    | Kenneth J. Brody | www.hvcomputer.com | #include |
    | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------+
    Don't e-mail me at: <mailto:>
     
    Kenneth Brody, Mar 30, 2007
    #18
  19. Kenneth Brody <> wrote:
    > Thomas Dickey wrote:
    >> Kenneth Brody <> wrote:
    >> > I, presonally, have used versions of termcap that had no concept
    >> > as "function keys" (ie: F1, F2, and so on). Of course, that was
    >> > some 20 years ago, and the modern implementations that I have seen
    >> > have entries for such keys. Whether any versions still exist that
    >> > do not support them, I cannot say.

    >> hmm. termcap stores the whole entry as a string. Function keys and
    >> other capabilities are string-capabilities with conventional (not
    >> standardized) names. So any termcap file can represent function keys.


    > Okay, let me clarify...


    You didn't have to (the time would have been better spent by checking).

    BSD 4.2 (I see the file's date July 1, 1983 - more than 20 years)
    distributed a termcap with k1, k2, etc., in its entries. A quick check
    shows 35 entries with _that_ much use of function keys.

    That convention is still in use. You may not have used or even been
    aware of it (there were manpages...), but other people used it, and
    assumed it.

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
     
    Thomas Dickey, Mar 30, 2007
    #19
  20. Thomas Dickey, Mar 30, 2007
    #20
    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:
    494
    Joe Smith
    Dec 12, 2004
  2. Craig

    Postback quit working

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

    Could not quit MSACCESS.EXE

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

Share This Page