Thread: Bloodshed Compiler/Run Error

  1. #1
    Registered User
    Join Date
    Jun 2008

    Bloodshed Compiler/Run Error

    I'm new to C++ and Bloodshed. I've copied a code directly from my book and have had it compile, but when I try to run it a black screen pops up for a millisecond then disappears, has anyone had this problem? Thank you

    #include <iostream>
    using namespace std;
    int main()
         cout<<"My first C++ Program!"<< endl;
         cout<<"The sum of 2 and 3 = "<< 5 << endl;
         cout<<"7 + 8 = " << 7 + 8 << endl;
         return 0;

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Yup, plenty of people have.

    Basically, just before the return 0, add this line:
    That should do for now.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Beautiful!...Thank you!

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    Since you're compiling a command line program, maybe try running it from an actual command line. Go to Start -> Run and run "cmd.exe". From there "cd" to the directory where you executable lives, and run it by name. The window stays open

    On UNIX we're used to these "console" things.

  5. #5
    Join Date
    Oct 2007
    Inside my computer
    Aside from cin.get() and the less convenient command prompt thing, there's also two other ways:
    - Get an IDE that can force the prompt to remain open after the program ends (Visual Studio and Code::Blocks are two that can do this, as I'm aware).
    - Use a debugger and put a breakpoint at the end of main (works beautifully in Visual Studio for one).
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

Tags for this Thread