please help me find a GREAT compiler

hi, im new to programing and im starting with c++. can someone please tell me what the best compiler is (in your opinion). i have dev c++ but it doesn't work with the source code that is written in a book that i am reading called "Sam's teach yourself c++ in an hour a day".

the code in the book is.

1
2
3
4
5
6
#include <iostream>
int main()
{
   std::cout << "Hello world!\n";
   return 0;
}

the problem is that it doesn't stay open.

it stays open and works when i type this.
1
2
3
4
5
6
7
#include <iostream>
int main()
{
   std::cout << "Hello world!\n";
   system("pause");
   return 0;
}

im not sure whats wrong, if its the compiler or a habit that i should get into (putting system("pause"); after all of my programs).
Wotcher.

First, I'd suggest that you move from Dev-C++ to either wxDev-C++ or Code::Blocks. Dev-C++ is a fossil. :|

Second, this isn't a problem with Dev-C++'s included compiler. It's an issue with Dev-C++ itself. It closes the console as soon as the program finishes, rather than pausing it automatically after the program is finished.

Third, please try to avoid using system() unless you can justify it perfectly. Duoas wrote up a pretty good article about why you should avoid the function when possible; if you check the Articles section of this forum, one of the stickied threads has a link to it. Also, there's a thread stickied at the top of this forum about how to keep the console open.

Happy coding!

-Albatross
In the first program, after it prints the message the program ends and thus the console closes.
http://www.cplusplus.com/forum/articles/7312/

This might help you for your other request:
http://www.cplusplus.com/forum/articles/7263/
Dev-C++ doesn't keep the console window open after the program terminates, that's all.
You shouldn't use Dev-C++ for various reasons, mainly because it is outdated.

Uninstall it, then go to the folder it was installed to and delete everything that is left to get rid of the outdated version of the compiler that comes with it.

Then install the Code::Blocks+MinGW package: http://www.codeblocks.org/
After that, you can manually upgrade to the latest version:
http://forums.codeblocks.org/index.php?&topic=14768.0
That is optional though - it will mainly improve code completion.

Edit: ah, getting slow.

The book you have is not to be recommended. If its author is Liberty, then it is a heavily abridged version of Teach Yourself C++ In 21 Days, which is a pretty bad book in itself.
You should either buy a decent book such as the C++ Primer or if you don't want to spend more money, you can read the "Thinking in C++" e-book:
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Last edited on
Topic archived. No new replies allowed.