Aug 7, 2010 at 4:33pm UTC
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!
Aug 7, 2010 at 5:24pm UTC
I didn't use any compiler for the book Accelerated C++
;^)
Post code & errors please
Aug 7, 2010 at 7:33pm UTC
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 Aug 7, 2010 at 7:36pm UTC
Aug 7, 2010 at 8:06pm UTC
Don't use Dev-C++ it's too old.
Borland C++ is even older.
Aug 7, 2010 at 9:00pm UTC
Please use [code]
tags.
And does the program close before or after you type the name?
Aug 7, 2010 at 9:02pm UTC
Bazzy - Okay well what do you suggest.
wasabi - Okay sorry, and it's after I type the name.
Aug 7, 2010 at 9:16pm UTC
_getch();
will need you to include the conio.h header file, same as you include <iostream> to use cout and cin
Aug 7, 2010 at 9:23pm UTC
So why wouldn't they tell me this in the book?
Aug 7, 2010 at 10:10pm UTC
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?