Press any key to...

Discussion in 'C++' started by JKop, Sep 16, 2004.

  1. JKop

    JKop Guest

    How in the name of Christ can I do this with Standard C++!


    std::cout << "Press any key to exit...";

    char k;
    std::cin >> k;

    doesn't work.

    All I want is one miserable keystroke.

    Does anyone else think that Google is crap for searching
    for programming related info?

    JKop, Sep 16, 2004
    1. Advertisements

  2. You can't do this in standard c++, because C++ only has buffered input.
    However, using a library local to your platform to accomplish this should be
    easy. For example, you might have the ncurses-library available on your

    / WP
    William Payne, Sep 16, 2004
    1. Advertisements

  3. JKop

    osmium Guest

    I can see why you say that. But it is easy to forget that there are main
    branches to google and this question is more likely to get results in google
    groups (the old Deja) than the main group. I went to google groups and
    typed "press any key" and got lots of promising looking hits on the first
    page. I must admit I didn't look at them but the combination of skimming
    and trying to guess what the newsgroup title means they are posted to are a
    help. Sometimes looking at the number of messages is useful too. You can
    also go to advanced search to limit the number of non-germane hits.
    osmium, Sep 16, 2004
    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.