How do
Results 1 to 5 of 5

Thread: How do

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

    Talking How do

    How do you tell a program to exit when you press a cetain button in C++
    The Many Signatures Of Me[gloworange]Moses Anderson[/gloworange]Moses Anderson [shadow]Moses Anderson[/shadow]

  2. #2
    GreekGoddess
    Guest
    #include <iostream.h>

    main()
    {
    cout << "Hello World!" << endl;
    return 0;
    }

    or:

    cout << “Press ENTER to continue…”;
    getch();
    return(0);
    }

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Posts
    1,027
    When you say "button" do you mean "key" or a button as in a graphical interface (meaning you are doing Visual C++ )

    Ammo
    Credit travels up, blame travels down -- The Boss

  4. #4
    Junior Member
    Join Date
    Oct 2002
    Posts
    6

    Arrow

    You should implement a kind of "event listener" .. a bit of code which looks after all the events in the sistem and runs continuously with your application, better as a separate thread. Then, when the keyboard is touched on the corresponding key, or the screen button is pressed -as U like- the listener will trigger the program exit (freeing the memory, closing all opened files, eventually closing used network connections, and so on).


    Good luck!
    Wh .. oops! Let\'s start over!

  5. #5
    Banned
    Join Date
    Jul 2002
    Posts
    877
    BurnByThee, Why the heck did you post the same thread twice only with a different name? You could have and should have atleast given peaple time to post instead of being such a impatiant thread poster.

Posting Permissions

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