Bloodshed Compiler/Run Error

This is a discussion on Bloodshed Compiler/Run Error within the C++ Programming forums, part of the General Programming Boards category; Hello, I'm new to C++ and Bloodshed. I've copied a code directly from my book and have had it compile, ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    13

    Bloodshed Compiler/Run Error

    Hello,
    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



    Code:
    #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
    Location
    Canada
    Posts
    8,047
    Yup, plenty of people have. http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    Basically, just before the return 0, add this line:
    Code:
    cin.get();
    That should do for now.
    dwk

    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: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

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

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,248
    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
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,772
    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, 03: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, 04:45 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

Tags for this Thread


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