Program disappears after running...?

This is a discussion on Program disappears after running...? within the C++ Programming forums, part of the General Programming Boards category; I'm following some tutorials in a book (C++ Programming for the Absolute Beginner), using the free Bloodshed compiler. I'm in ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Location
    Lompoc, CA
    Posts
    2

    Program disappears after running...?

    I'm following some tutorials in a book (C++ Programming for the Absolute Beginner), using the free Bloodshed compiler. I'm in the very beginning stages of learning (Hello World!) but when I compile and run, or just run the program after compiling and saving, it disappears in an instant. I need to see the output to see if I'm doing this right. Any ideas?

    Thanks!

    REN

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User Osaou's Avatar
    Join Date
    Nov 2004
    Location
    Stockholm, Sweden
    Posts
    69
    The problem is your program probably only does the following:

    1) Enters code to execute
    2) Prints "Hello World!"
    3) Exits...

    I.e. somethng like the following:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(){
    	cout << "Hello World!";
    }
    Now, console programs compiled with Bloodshed are automatically terminated when code execution is complete. So, you need a way to make the program wait after you've printed "Hello World!"...

    One way is to make it wait until you push a button. Here's how that can look in Bloodshed:
    Code:
    #include <iostream>
    #include <conio.h>
    
    using namespace std;
    
    int main(){
    	cout << "Hello World!";
    	getch();	// wait for user to push a key
    }

    Edit:
    Bah, too late... and I guess the above answers are somewhat better if you're just starting off... =)

  5. #5
    Registered User
    Join Date
    Jul 2006
    Location
    Lompoc, CA
    Posts
    2
    You all rock. I did a forum search (wrong terms), but didn't check the FAQ.

    Thanks! I'm trying to figure out C++ so I can program plugins for 3D. Good to know there's a place with knowledge like this!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding Program Running Time
    By pf732k3 in forum C Programming
    Replies: 6
    Last Post: 03-18-2008, 02:56 PM
  2. Running my program in the background
    By shoobsie in forum Windows Programming
    Replies: 4
    Last Post: 10-09-2005, 03:38 AM
  3. Replies: 3
    Last Post: 09-05-2005, 09:57 AM
  4. Why is my program running away?
    By badkitty in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2001, 05:27 PM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 11:57 AM

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