Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Apr 2006
    Location
    London, United Kingdom
    Posts
    370

    Dev C++ & Compiling.

    So.. I started up the C++ VTM's that I bought from Buzz again. Last time around I used the Microsoft IDE thingy.. and it seemed to install a ton of crap on my computer =(

    So, this time around, I decided to try out DevC++. I went through the HelloWorld program, but it never ran my program. The console flashed up and then closed really quickly. I ran to the stickies and tried all of the solutions. Adding those things to the bottom of my code didn't effect anything and just ended up giving me a ton of errors =/ When I put them inside the 'main' function, the console would stay up.. but HelloWorld was nowhere to be found =(

    I've been searching for a fix for a while, and I'm giving up for the night =/
    If anyone knows how to fix this, please let me know!
    Maybe I should've stuck with Microsoft? I guess that 'crap' made it work right. =P
    If you're happy and you know it, clap your hands!

  2. #2
    Join Date
    Mar 2002
    Location
    Netherlands
    Posts
    52
    First of all I can recommand you to use code::blocks or eclipse version of c++. These are the free IDE's who have the best support and still in development comparing to dev c++. Both can be used for free and they also do crosscompiling.

    Aside from the fact that is the normal behavior of a program to close when no imput is requested you can use either one of these commands to keep you program window open

    cin.get(); // keeps window open until user presses enter.
    or

    system("PAUSE"); // Keep window open until input

    or

    Set a break point on the last statement when debugging this will achief the same.


    There are 2 more ways to do it but I can't remmeber them right know but these will work just as fine

  3. #3
    Join Date
    Mar 2004
    Posts
    0
    Please post your code so we can determine what exactly is being done incorrectly. There are no reasens why dev c++ would produce software that does not do what it should. Please post your code

  4. #4
    Join Date
    Mar 2002
    Location
    Netherlands
    Posts
    52
    The code does what it suppose to do, the only problem he had is that the window would close on exit. Apparently he would liked to see the result before the window closes.

  5. #5
    Join Date
    Mar 2004
    Posts
    0
    I understand that. But he also said he tried everything suggested in the TOI. So apperently he is not placing the code in the correct place. If he would post his code like I suggested, then we can tell him exactly where to place the code.



  6. #6
    Join Date
    Mar 2006
    Location
    South Australia
    Posts
    4,521
    Code:
    system("pause");
    ??

  7. #7
    Join Date
    Apr 2006
    Location
    London, United Kingdom
    Posts
    370
    There is a screenshot below.

    If I put the code anywhere other than inside the int main(){ I get back a bunch of errors. And, when I put it inside, the console stays open, but the program isn't there?

    If you're happy and you know it, clap your hands!

  8. #8
    Join Date
    Feb 2007
    Location
    Riverside, CA
    Posts
    257
    Quote Originally Posted by Cynosure View Post
    There is a screenshot below.

    If I put the code anywhere other than inside the int main(){ I get back a bunch of errors. And, when I put it inside, the console stays open, but the program isn't there?

    You need to put the cin >> x after your Hello World line.

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    	int x;
    	
    	cout << "Hello World";
    	cin >> x;
    
            return 0;
    }
    Last edited by DanMulvey; 09-27-2007 at 10:12 AM.
    10 PRINT "The cake is a lie"
    20 GOTO 10

  9. #9
    Join Date
    Jun 2005
    Location
    NY
    Posts
    1,374
    First off(don't worry I say this to everyone ). You should make main int main() and not just main(), though it may work on some compilers there is no guarantee that it will work on all of them, this is due to the internationally agreed upon standard for C++(link in the Thread Of Information).
    Second, at the end of main, right before the '}' close brace, you should put return 0(also due to the standard). Trust me, it will be better to do this now than fall into these bad habits and have to try and change them.(I know that is what its like in the video).

    Second, if you want the console to stay open you could use std::cin.get() after the cout statement. And the console will stay up until 'enter' is pressed.

    And to Mr_Charisma: system() just executes a system command. So on Windows at least, the "Pause" command just pauses the application until user input. Its not a great way to solve this problem, since the same command is not guaranteed on all OSs.
    CodeGuru: DLL Tutorial For Beginners by me. Rated 4 1/2 out of 5.

  10. #10
    Join Date
    Jan 2007
    Posts
    50
    I believe that its
    system("PAUSE") and not system("pause")

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •