Console Problems

This is a discussion on Console Problems within the C++ Programming forums, part of the General Programming Boards category; Hey people, I'm a newbie at C++ and am taking things nice and slowly for the moment. I've created my ...

  1. #1
    Resident Programming Nut
    Join Date
    Oct 2004
    Posts
    1

    Unhappy Console Problems

    Hey people,

    I'm a newbie at C++ and am taking things nice and slowly for the moment. I've created my first C++ program "Hello World". It compiles correctly but when i run the program all it does is pop up and disappear in less than a second. The code is as follows:
    /**************************************************/
    #include <IOSTREAM>

    int main ()

    {
    std::cout << "Hello World!\n"; // Displays Hello World
    return 0;
    }
    /**************************************************/
    I can't figure out what's going wrong. I'm using Dev C++ to create my programs. Can anyone give me any pointers as to the problem? Could it be to do with the enviroment or compiler options?

  2. #2
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    The FAQ has a lot of useful answers in it. I suggest you peruse it sometime.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Welcome to the board
    Please use &#91;code]&#91;/code] tags around your future code posts.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I notice the new VC++ 8 compiler actually pauses after a program whether or not you add code to tell it to do so. You could always just switch to this compiler if you are a winbloze user.

  5. #5
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    MinGW Studio does the same. And honestly I would suggest it over anything else (free wise).

    Check out the link in my signature.

    Also, the reason it does this is because it is the "debug" build of the application. So the "release" build wont have that.

    And a quick answer to your question.

    Code:
    #include <iostream>
    
    int main ()
    {
     
        std::cout << "Ah";
        
        // This will wait for you to hit enter
        std::cin.get ();
        return 0;
    
    }
    Still, go and read the FAQ. Alot of good stuff in there.
    What is C++?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. Told ya so...
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 58
    Last Post: 09-12-2007, 08:12 PM
  3. CreateProcess and console handles
    By manannan in forum Windows Programming
    Replies: 1
    Last Post: 11-12-2005, 01:17 AM
  4. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 09:59 PM
  5. Console Functions Help
    By Artist_of_dream in forum C++ Programming
    Replies: 9
    Last Post: 12-04-2004, 02:44 AM

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