Problem with Hello World program

This is a discussion on Problem with Hello World program within the C++ Programming forums, part of the General Programming Boards category; Yep, new guy on the path of C++ I'm using Dev C++ Code: // a simple "Hello World" program! #include ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    1

    Problem with Hello World program

    Yep, new guy on the path of C++

    I'm using Dev C++

    Code:
    // a simple "Hello World" program!
    
    #include <iostream>
    
    int main()
    
    {
        std::cout << "Hello World!" << std::endl;
        return 0;
    }
    It compiles it, but when I run it nothing happens. I've tried the system pause command aswell, when I tried it a black console came up, but then went away a second later.

    Correct me if I'm wrong but is there something that can wait until you've pressed a key hen disappear?

    Thanks

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    10
    Code:
    // a simple "Hello World" program!
    
    #include <iostream>
    
    int main()
    
    {
        std::cout << "Hello World!" << std::endl;
    	while(1){}
        return 0;
    }
    i'm not an expert. the while loop should pause the program.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,170
    A while loop is a very bad thing™, because it will consume 100&#37; cpu on one core.
    There are a few ways to solve this.
    - Use a debugger and put a breakpoint.
    - Add cin.get() add the end.
    - Use an IDE that has the option to keep the console open after the program ends (Visual Studio, for example).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I have finished my program, one problem
    By sloopy in forum C Programming
    Replies: 4
    Last Post: 11-29-2005, 01:10 AM
  2. Program problem
    By Birdhaus in forum C++ Programming
    Replies: 6
    Last Post: 11-21-2005, 09:37 PM
  3. Some Problem With My Program
    By Americano in forum C Programming
    Replies: 5
    Last Post: 10-18-2003, 01:58 AM
  4. Problem with Program not Quitting
    By Unregistered in forum Windows Programming
    Replies: 20
    Last Post: 06-11-2002, 11:06 PM
  5. Console Program Problem
    By Breach23 in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2001, 12:35 AM

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