Code::Blocks Forums

User forums => Help => Topic started by: ultrabot90 on March 17, 2007, 10:40:00 am

Title: Unable to run.
Post by: ultrabot90 on March 17, 2007, 10:40:00 am
I'm new to C::B, hence I dont know too much about this IDE. I created a Hello World program to check out C::B, and compiled it - zero errors...But I when I looked in "Build" menu...I find that all the options are greyed except for "Compile Current File", "Errors" (just "Clear all errors" available), and "Compiler Options"...T_T
Also, it got a warning for using outdated header files (I used <iostream.h> instead of <iostream> etc). And when I removed the ".h" from it, I get a load of errors that I havent declared a cin and cout >.>
Please help.
-regards,
ultrabot90
Title: Re: Unable to run.
Post by: Biplab on March 17, 2007, 11:00:47 am
When you are including <iostream> you've to define the namespace where compiler can find out cin , cout and others. Type in the following code and it should run perfectly.

Code
#include <iostream> // Basic header for IO

using namespace std; // Tell compiler that we're using std namespace

int main ()
{
    cout << "Hello World!" << endl;
    return 0;
}

Regards,

Biplab
Title: Re: Unable to run.
Post by: ultrabot90 on March 17, 2007, 11:12:05 am
Thanks for the tip ;)
Any help for the first (and most cruicial problem?) Or is there some detail I've left out? o.0
Title: Re: Unable to run.
Post by: Biplab on March 17, 2007, 11:26:35 am
My guess you didn't create a project. Try creating a Project first (For your case, a Console Project should be created).
Title: Re: Unable to run.
Post by: ultrabot90 on March 17, 2007, 11:33:56 am
Hm...that does seem to be the problem...Yeah, thats cracked it! w00t. Thanks a load. I used Borland Turbo C++ 4.5 earlier, and it didnt seem to have this project system. Hence such a n00bzor question. Thanks again. :D