Message "Press any key to continue"

Discussion in 'C++' started by Timur Ametov, Apr 26, 2006.

  1. Timur Ametov

    Timur Ametov Guest

    Hallo everybody.
    I'm using Visual Studio 7 and hier is my question. How can i see in
    Outputwindow after my Programm ended the message "Press any key to
    continue". Is it possible? Now this window will closed automatisch.

    Thank you
     
    Timur Ametov, Apr 26, 2006
    #1
    1. Advertisements

  2. Timur Ametov

    utab Guest

    Your window will flash some time (and this time period is so short you
    wont be able to see the output) in DOS mode and you will have to add
    some conio.h functions(getch() before return). But if I am not mistaken
    VC++ gives you an option for you to press any key to close that black
    DOS mode window so you dont need to do anything special.

    This is only a suggestion: If you have the option, try to compile under
    linux/Unix using g++ or under windows try programs that emulate UNIX
    like environments(like cygwin...)

    I do not know if I got your question right.

    Regards
     
    utab, Apr 26, 2006
    #2
    1. Advertisements

  3. Timur Ametov

    Timur Ametov Guest

    But if I am not mistaken
    That is the problem. I don't know, how or where can I enable this option.
    The help is written part in english, part in german, so that to search the
    answer there is a bad idea :(
     
    Timur Ametov, Apr 26, 2006
    #3
  4. Timur Ametov

    Kyle Small Guest

    system("pause");
     
    Kyle Small, Apr 26, 2006
    #4
  5. Timur Ametov

    Timur Ametov Guest

    system("pause");

    Thank you. It works.

    Tim(ur)
     
    Timur Ametov, Apr 26, 2006
    #5
  6. Timur Ametov

    Marcus Kwok Guest

    Please do not top post, and do not trim attribution lines (added back
    in).

    This is not portable. If the OP can relax his restriction to the
    <Enter> key instead of any key, then a portable way to do this is
    something like:

    std::cout << "Press <Enter> to continue\n";
    std::string trash;
    std::getline(std::cin, trash);
     
    Marcus Kwok, Apr 26, 2006
    #6
  7. I believe the Press any key message appears automagically in Visual C++
    when running one of the Debug or Release builds, not sure exactly which
    one (it's the one you're not currently using)./
     
    stefan.ciobaca, Apr 26, 2006
    #7
  8. Timur Ametov

    Timur Ametov Guest

    I believe the Press any key message appears automagically in Visual C++
    I also believed that, but it is not so and i don't know where can i enable
    this feature.

    Tim
     
    Timur Ametov, Apr 27, 2006
    #8
  9. Timur Ametov

    Default User Guest

    OT, but my version of VSC++6 certainly does that.

    If you have trouble setting up your IDE, you need to go to a newsgroup
    dedicated to it. This is not the place to discuss your implementation.

    If you want a platform-independent method, request the users to HIT CR
    TO CONTINUE and use some sort of read from standard in to consume all
    input up to the new-line.




    Brian
     
    Default User, Apr 27, 2006
    #9
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.