Thread: I need help!

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    36

    Question I need help!

    I just started in C++, and I downloaded a complier called Bloodshed Dev-C++ beta of the newest version. I wrote a simple program, tested it for errors and compiled it. When I tried to execute the code, a Comand Prompt window opens up, and the end result of my program is in there. Only problem is that the window pops up for like less than a second and then it closes.

    Does anybody know what is happening and how I can fix this?


  2. #2
    Registered User
    Join Date
    Aug 2004
    Posts
    193
    Add std::cin.get(); before return 0; and it waits for user to hit enter before it closes. I hope that helps so it would look like:

    Code:
    #include <iostream>
    
    int main()
    {
    std::cout << "Hello!";
    std::cin.get();
    return 0;
    }
    Last edited by stickman; 09-03-2004 at 05:15 PM.

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Try reading this FAQ which points you to this FAQ which has several possible solutions.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    36
    Hey stickman! U know how helpful that was? I finally got the window to stay! By the way this is my first day of C++. My program was just simple addition. I added 6 and 4 together.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Aug 2004
    Posts
    193
    That link was already posted just to let you know.

    EDIT: No problem on the window staying up thing. I had that question when I first started also. A lot of people have helped me so I want to help back.

Popular pages Recent additions subscribe to a feed