Exiting Programs
Results 1 to 3 of 3

Thread: Exiting Programs

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    8

    Exiting Programs

    [gloworange]How do i tell the computer to exit the program when Q and enter is pressed. I just started writing in it and i want to know how. I have tried giving it a command line saying close screen and window and program when those to are pressed but nothing works. Help me please [/gloworange]

    i wrote it in C++
    The Many Signatures Of Me[gloworange]Moses Anderson[/gloworange]Moses Anderson [shadow]Moses Anderson[/shadow]

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Posts
    394
    does it absolutely have to be when q AND enter are pressed?

    if this is from a menu, or switch statment, you could use "exit(0);" without the quotes.

    if you want a process to repeat until a key is pressed, you could #include <conio.h> and then do something like,
    while( !_kbhit() ) {
    do this;
    };

    or

    for( ;; ) {
    do this;
    if( _kbhit() ) exit(0) ;
    }

    the switch statment might look like,

    switch ( variable ) {
    case '1' : whatever ;
    break ;
    case 'q' : exit(0) ;
    break ;
    default : exit(1) ; // where the "1" means that an error has occured.
    }

    once again, im not sure about two keys being pressed together to trigger an event. but perhaps if you are more specific with your problem then you will find answers.
    hand.
    Hmm...theres something a little peculiar here. Oh i see what it is! the sentence is talking about itself! do you see that? what do you mean? sentences can\'t talk! No, but they REFER to things, and this one refers directly-unambigeously-unmistakably-to the very sentence which it is!

  3. #3
    Junior Member
    Join Date
    Sep 2002
    Posts
    8

    Exiting Programs

    I mean type in a key then press enter to make it go through to make the program end
    The Many Signatures Of Me[gloworange]Moses Anderson[/gloworange]Moses Anderson [shadow]Moses Anderson[/shadow]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •