Thread: Making a getch and kbhit function?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212

    Making a getch and kbhit function?

    Anyone know what code I'd need for these functions? [dos/windows], because the Dev-C++ versions of these functions are pretty ****ed up.

    Code:
    int getch(void)
    {
     /* blah blah blah*/
    }
    Code:
    int kbhit(void)
    {
     /*blah blah blah*/
    }

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    To get alternative versions (that probably work as you'd expect), include conio_mingw.h instead of conio.h.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    If your problem is to stop the program until the user hit a key, you could use this:
    Code:
    void pause(void)
    {
      puts("press enter to continue");
      getc;
    }
    At least this would be ANSII-conform. (In spite of the getch() and kbhit() functions.)

    klausi
    When I close my eyes nobody can see me...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. kbhit() for linux.
    By jamie85 in forum C Programming
    Replies: 11
    Last Post: 11-03-2008, 08:19 AM
  2. kbhit() and getch() Equivalent..
    By ThLstN in forum C Programming
    Replies: 1
    Last Post: 03-11-2008, 02:44 AM
  3. Replies: 5
    Last Post: 11-26-2002, 10:34 PM
  4. Pausing for input, with kbhit() still detecting keys
    By Da-Spit in forum C++ Programming
    Replies: 5
    Last Post: 05-23-2002, 05:04 AM
  5. Getting the char from kbhit()
    By CodeMonkey in forum C++ Programming
    Replies: 5
    Last Post: 03-24-2002, 11:10 AM