Compiling Issues with Accelerated C++

Hey guys, this is my first post of this forum and hopefully not my last, but I have just one question:

Which compiler did you use for the book Accelerated C++?

I am using Code::Blocks with the Borland C++ Compiler and on chapters 1.1, I am having compiler issues.

Thanks!
I didn't use any compiler for the book Accelerated C++
;^)
Post code & errors please
Okay so a big update!

I just changed my Compiler to Dev-C++ and the program works. Here is the code:

#include <iostream>
#include <string>
using namespace std; // I did this to save time from all of the "std::cout/cin" stuff.

int main()
{
cout<< "Please enter your first name: \n";
string name;
cin>> name;
cout<< "Hello, " << name << "! \n";
return 0;
}

When I compile and execute the program, it opens and closes rapidly.

Thanks!
Last edited on
Don't use Dev-C++ it's too old.
Borland C++ is even older.
Please use [code] tags.

And does the program close before or after you type the name?
Bazzy - Okay well what do you suggest.

wasabi - Okay sorry, and it's after I type the name.
I use CodeBlocks 10.05 wit GCC 4.5.0
see http://www.cplusplus.com/forum/articles/7263/
Well, after you type the name, the program does exactly what you tell it to do. It displays the name and then it ends and closes itself. You need to ask the program do stop, the best way is to put
1
2
getch();
getch();
after the cout line.
_getch();

will need you to include the conio.h header file, same as you include <iostream> to use cout and cin
So why wouldn't they tell me this in the book?
because conio.h is not standard, it's old and not portable
btw http://www.cplusplus.com/forum/articles/7312/

wow.. thanks for the update..

anytime I've used flush though, even if there is nothing in the buffer, it skips right over..

to be able to use any key, you could just use cin.ignore(1, '\n'); right?
Topic archived. No new replies allowed.