Probably Very Easy Help

This is a discussion on Probably Very Easy Help within the C++ Programming forums, part of the General Programming Boards category; Could anyone tell me why this doesn't work please?? Code: #include <iostream> #include <conio.h> using namespace std; int main() { ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Question Probably Very Easy Help

    Could anyone tell me why this doesn't work please??

    Code:
    #include <iostream>
    #include <conio.h>
    
    using namespace std;
    
    int main()
    {
      do
      {
        cout << "Still in the do...while loop" << endl;
      } while(!kbhit());
    
      return EXIT_SUCCESS;
    }
    Thanks.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    How does it not work?

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    Also, I'm using Dev-C++ if it makes a difference.

    It says something like kbhit isn't defined and neither is EXIT_SUCCESS.

    Something like that, I don't understand it too much.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Well, you can always add this to the top of your code to take care of the one:

    #ifndef EXIT_SUCCESS
    #define EXIT_SUCCESS 0
    #endif

    kbhit is NOT ANSI C, and as such, the ported Unix compilers won't know it.
    I'm not sure how to do a C workaround (I've forgotten a lot of C's i/o, I know how to do a kbhit-like function in C++...)

  5. #5
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Include conio_mingw.h instead of conio.h.
    zen

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    Ok. My code now is...

    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <conio_mingw.h>
    
    using namespace std;
    
    int main()
    {
      do
      {
        cout << "Still in the do...while loop" << endl;
      } while(!kbhit());
    
      return EXIT_SUCCESS;
    }
    Is there an easier way (keeping the code from the first post) or will this do??

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Easy String position question...
    By Striph in forum C Programming
    Replies: 4
    Last Post: 05-11-2009, 09:48 PM
  2. Seg fault in easy, easy code
    By lisa1901 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2007, 05:28 AM
  3. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 04:56 AM
  4. Easy question, (should be) easy answer... ;-)
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-12-2002, 10:36 PM
  5. Replies: 20
    Last Post: 05-25-2002, 08:14 PM

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