Ahh the helpful FAQ

This is a discussion on Ahh the helpful FAQ within the C++ Programming forums, part of the General Programming Boards category; I am somewhat new to programming in C++, but not so much that I can't navigate it well. I go ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    11

    Question Ahh the helpful FAQ

    I am somewhat new to programming in C++, but not so much that I can't navigate it well. I go between 2 different versions of Visual C++ IDE, Visual C++ 6 and Visual C++.net 2002 std. I tried the suggestions in the FAQs "How do I Stop my Windows Console from disappearing everytime I run my program?" and " How do I get my program to wait for a keypress?" but it only works rarely. Is there an option hiding somewhere in the IDE to make it wait for a keypress? The cin.get() method does nothing for me. Can anyone help?

    Meeloff

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    94
    You could try using kbhit()...for example

    Code:
    int main ()
    {
        cout << "\nThis is a test to see kbhit()";
        cout << "\n Prog. will not continue until you press enter";
    
        while(!(kbhit()));
    
        cout << "\n You hit enter";
        return 0;
    }
    simple is always an understatement.....

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If you're getting input from the user in your program, try putting cin.get( ) twice. Or you could #include <cstdlib> and system ("pause");.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    It only works rarely? You sure you start your apps with Ctrl+F5?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    that could be it... if you're getting user input, some methods leave the '\n' in the stream, so the next cin.get() will just grab that as user input... if you have a cin or something just put cin.ignore(); after it. that should clear the input stream.

    I prefer bloodshed's Dev-C++ compiler over any other windows compiler...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wiki FAQ
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 192
    Last Post: 04-29-2008, 02:17 PM
  2. FAQ Check/Lock
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-15-2002, 12:21 PM
  3. FAQ - it is not a true list of FAQ
    By alpha561 in forum C Programming
    Replies: 1
    Last Post: 05-25-2002, 07:40 PM

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