Compiler Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • curls8
    New Member
    • Feb 2008
    • 24

    Compiler Question

    I am starting to get back into C++ Programming. I am a beginner. Can someone let me know what type of compiler is the best. Is it worth it to buy one or are the free ones good enough. Please list your favorite compiler too.
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    Get a free one. The free compilers are good enough that you don't need to pay anymore. If you're using Windows, grab Dev-C++ or Cygwin if you want some Unix in your Windows. MinGW is also a thought. I use Linux, so gcc comes standard and thus I don't really have a 'favorite' compiler/IDE. Actually...Visu al Studio is free now, isn't it? That's not a horrible choice (recommending nearly anything Microsoft makes sticks in my craw).

    Comment

    • arnaudk
      Contributor
      • Sep 2007
      • 425

      #3
      As far as windows is concerned I wouldn't recommend MinGW's gcc as I've had some strange problems problems with it (which I didn't have using gcc on linux or mac). Get a compiler specifically made for windows, like the one that comes with VC++ express (it's free).

      Comment

      • curls8
        New Member
        • Feb 2008
        • 24

        #4
        Originally posted by Laharl
        Get a free one. The free compilers are good enough that you don't need to pay anymore. If you're using Windows, grab Dev-C++ or Cygwin if you want some Unix in your Windows. MinGW is also a thought. I use Linux, so gcc comes standard and thus I don't really have a 'favorite' compiler/IDE. Actually...Visu al Studio is free now, isn't it? That's not a horrible choice (recommending nearly anything Microsoft makes sticks in my craw).
        Thanks, I just downloading Dev-C++. I just tried to make a simple Hello World, it compile find, but when I tell it to Run a small black screen just flashes and that is it, I am not seeing my program excute. Do you happen to know what is wrong?

        Comment

        • oler1s
          Recognized Expert Contributor
          • Aug 2007
          • 671

          #5
          Nothing is wrong. Your program is doing exactly what it is supposed, and so is Windows. You don’t have a console window open, so when you run a console program (the kind you just created), Windows opens up a console for you, runs the program there, and then closes the console when the program is done.

          The correct way:
          Learn to use the Windows console to run programs. There is a powertoy called “Open Command Window Here” or something along those lines. Comes in pretty handy, I think.

          Might be possible:
          I know this is true in Visual Studio, but I don’t recall for Dev-C++. There may be a way to run the program from Dev-C++, and have the IDE force the window to stay open. Look at the different ways you can run it. “Debug” is also one way to run the program, and may force the window to stay open.

          The bad way:
          Put a hack in your program. Look on Google for all the different hacks people have come up with to avoid doing it the correct way.

          Comment

          • curls8
            New Member
            • Feb 2008
            • 24

            #6
            Originally posted by arnaudk
            As far as windows is concerned I wouldn't recommend MinGW's gcc as I've had some strange problems problems with it (which I didn't have using gcc on linux or mac). Get a compiler specifically made for windows, like the one that comes with VC++ express (it's free).
            I downloaded the Dev-C++ MinGW's gcc one before I saw this. Should I remove it and install a next one. There is an excutable only one and a source code.

            Comment

            • curls8
              New Member
              • Feb 2008
              • 24

              #7
              Originally posted by oler1s
              Nothing is wrong. Your program is doing exactly what it is supposed, and so is Windows. You don’t have a console window open, so when you run a console program (the kind you just created), Windows opens up a console for you, runs the program there, and then closes the console when the program is done.

              The correct way:
              Learn to use the Windows console to run programs. There is a powertoy called “Open Command Window Here” or something along those lines. Comes in pretty handy, I think.

              Might be possible:
              I know this is true in Visual Studio, but I don’t recall for Dev-C++. There may be a way to run the program from Dev-C++, and have the IDE force the window to stay open. Look at the different ways you can run it. “Debug” is also one way to run the program, and may force the window to stay open.

              The bad way:
              Put a hack in your program. Look on Google for all the different hacks people have come up with to avoid doing it the correct way.
              So is there any free program that let me see my work? I am going to try the 'correct way' although I have no idea what it is. Is it something already on my computer or should I just google it?

              Comment

              • curls8
                New Member
                • Feb 2008
                • 24

                #8
                Ok so the Console is the C Prompt, do I just program in there. Is there a frustration smilie. I am trying to do a quick program fast while my toddler is busy and this is a huge setback. (Ok breathe..)

                I saw a small example of how to do it on Yahoo answers. It is looking familiar like what I used in school.

                I think I find a way I will try it out in a while as toddler now wants attention.

                Ok.. back to the drawing board. I tried the debug thing and the cin.get(); and it still flashes off. Now off to learn the Window Console.

                Comment

                • curls8
                  New Member
                  • Feb 2008
                  • 24

                  #9
                  I just tried the cin.get(); again, and it leaves the window open. I guess I did something wrong in the beginning. so I guess I will just use that for now.

                  Comment

                  • janders468
                    Recognized Expert New Member
                    • Mar 2008
                    • 112

                    #10
                    If you want the console window to stay open then add a line of code that says system("Pause") ;
                    Should hold it open for you, I believe this only works in windows, just in case you were to try it on another os, I could be wrong though.

                    Comment

                    • Ganon11
                      Recognized Expert Specialist
                      • Oct 2006
                      • 3651

                      #11
                      Adding system("pause") as the last line before "return 0" in main() has been my standard solution when faced with this problem.

                      Ideally, you would compile your program using Dev, but then get to your program using DOS and run it that way. Then the program would run, the output would be generated, and control would return to you - without ever closing the window.

                      Comment

                      • curls8
                        New Member
                        • Feb 2008
                        • 24

                        #12
                        Thanks everyone, it did help.

                        Comment

                        • Sick0Fant
                          New Member
                          • Feb 2008
                          • 121

                          #13
                          Originally posted by curls8
                          Thanks, I just downloading Dev-C++. I just tried to make a simple Hello World, it compile find, but when I tell it to Run a small black screen just flashes and that is it, I am not seeing my program excute. Do you happen to know what is wrong?
                          I used to like to put in a scanf at the very end, so that it would stay until I hit ctrl+c. :-)

                          Comment

                          Working...