AL_DA_GREAT
Aug 30, 2006, 11:00 AM
I need a c++ compiler. It has to be free and I want to download it. please send link to website where I can do this. thanx
|
View Full Version : c++ compiler AL_DA_GREAT Aug 30, 2006, 11:00 AM I need a c++ compiler. It has to be free and I want to download it. please send link to website where I can do this. thanx Speedo Aug 30, 2006, 11:01 AM Google "Dev C++" AL_DA_GREAT Aug 30, 2006, 11:44 AM one more question why won't dev x compile this:It said something about cout being undeclared //include this file for cout #include <iostream> int main() { //print out the text string, "Hello, World!" cout << "hello world\n"; return 0; } Ginger_Ale Aug 30, 2006, 12:29 PM Yeah, you need to either write: std::cout << "Hello World!"; or, before int main(), write: using namespace std; Speedo Aug 30, 2006, 01:42 PM "cout" is in the std namespace. You have to tell the compiler where to look for cout, there are 3 ways to do so: 1. Use the scope resolution operator "::" every time you use cout, so every instance would appear as std::cout. 2. Use the declaration "using std::cout;" before your main function. So, everytime the compiler sees "cout", it will use the instance in the std namespace. 3. Use the declaration "using namespace std;", will use the std namespace throughout your entire program. Not a problem in most simpler programs, but potentially so in more complex ones where you would need to use multiple namespaces. AL_DA_GREAT Aug 31, 2006, 01:22 AM every time I compile something and try to open it in an exe format all I get is a black window that diappears in a fraction of a second Speedo Aug 31, 2006, 06:19 AM I presume you are running from within the Dev C++ IDE- Programs such as your "Hello World" type that just run through a few commands and exit will do this. You can either add a command to make the program hold before it exits, or compile and run from the command line, which eliminates the problem (since the window the program runs in stays open). Option 1: Add the line "system("pause");" at the very end of your program, right before the main function returns. Will make the program hold at that point until you press a key. Option 2: Use the command line. Go to Start>Run, enter "cmd" to start it. Use the command 'cd "c:\my folder\whereever i store C++ files" to browse to your files Compile with "g++ mycppfile.cpp -o whatIwantmyfilenamed.exe -Wall" Enter the file name to run it. homeyg Aug 31, 2006, 07:35 PM No! Add this to keep the program up: cin.get(); //add it right before return 0; return 0; Souron Aug 31, 2006, 11:21 PM I agree with homeyg, cin.get is better than system("pause"). You may need cin.ignore to be the line before though. AL_DA_GREAT Sep 01, 2006, 10:41 AM thanx it works now Phlegmak Sep 05, 2006, 12:57 PM I need a c++ compiler. It has to be free and I want to download it. please send link to website where I can do this. thanx Search for gcc or g++. I use Cygwin on Windows and g++ comes with Linux. |
vBulletin® v3.6.8, Copyright ©2000-2009, Jelsoft Enterprises Ltd.