help please

This is a discussion on help please within the C++ Programming forums, part of the General Programming Boards category; hi! i'm looking for a code or syntax that will make my program end if and ONLY if you press ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    6

    Unhappy help please

    hi! i'm looking for a code or syntax that will make my program end if and ONLY if you press any key on the keyboard

  2. #2
    Registered User GL.Sam's Avatar
    Join Date
    Aug 2009
    Posts
    88
    What OS do you use?

  3. #3
    Registered User kakayoma's Avatar
    Join Date
    Jul 2009
    Location
    Dallas, Texas
    Posts
    42

    Post

    For windows you have to use wm_char to process it

    i reccomend you learn win32 programming.

    Vista - Something We all Love to Hate.

  4. #4
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    i reccomend you learn win32 programming.
    You do not have to learn win32 programming just to get a program to wait for a keypress.
    Here, try this - Cprogramming.com FAQ > How do I get my program to wait for a keypress?
    Spidey out!

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    51
    Quote Originally Posted by Spidey View Post
    You do not have to learn win32 programming just to get a program to wait for a keypress.
    Here, try this - Cprogramming.com FAQ > How do I get my program to wait for a keypress?
    While this is probably what he wants, that's not specifically what he asked for.

    The original request was for ending on a keypress, which very well could mean breaking out of an infinite loop that would run until a key was pressed. In that case, more details are needed.

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    I say, that gives all the needed information to make the code work.
    We're not here to hand out solutions to how exactly you must write your code to break out of a loop when pressing a key, for example. The logic bit the programmer must do him/herself. It's imperative that the programmer knows how to create the code for certain logic.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Is this so hard?

    Code:
    #include <conio.h>
    
    int main()
    {
        while(!_kbhit());
        return 0;
    }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21