PDA

View Full Version : Is it Geany or my problem???



phantomgunex
November 9th, 2008, 11:52 AM
Hey! i just created a simple hello world program in Geany:

#include <iostream>

int main(int argc, char** argv)
{
cout << "Hello World!" << endl;

return 0;
}

But got this errors:
project.cpp:28: error: ‘cout’ was not declared in this scope
project.cpp:28: error: ‘endl’ was not declared in this scope

Is there something wrong with my program or is there something about Geany that is not letting me compile it?

Thanks!

cmay
November 9th, 2008, 12:14 PM
you need to use namespace std


#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "Hello World!" << endl;

return 0;
}
or


#include <iostream>
int main(int argc,char**argv)
{
std::cout<<"hello again"<<std::endl;
return 0;
}
if you do not use the namespace std.

phantomgunex
November 9th, 2008, 02:50 PM
thanks! You saved my life
:KS

LaRoza
November 9th, 2008, 06:03 PM
Hey! i just created a simple hello world program in Geany:

Is there something wrong with my program or is there something about Geany that is not letting me compile it?

Thanks!

Are you just learning C++ and doing a test run or did you not know about namespaces?

phantomgunex
November 10th, 2008, 04:53 AM
lol i am learning c++. i borrowed "C++ for dummies" from the library and it used dev-c++ but i could not compile the source i downloaded, so i used geany but apperently i cannot just copy the codes into the book just like that. The header used in the book is

#include <iostream>
#include <stdlib.h>
but i cant use it in geany.

LaRoza
November 10th, 2008, 04:57 AM
lol i am learning c++. i borrowed "C++ for dummies" from the library and it used dev-c++ but i could not compile the source i downloaded, so i used geany but apperently i cannot just copy the codes into the book just like that. The header used in the book is

#include <iostream>
#include <stdlib.h>
but i cant use it in geany.

That book is...weird.

iostream is a C++ like, stdlib.h is for C (cstdlib would be for C++)

If you are just starting programming, I suggest you check out the stickies, my site, and wiki. I started with C++ from a book I randomly got, I regret it.

phantomgunex
November 10th, 2008, 05:02 AM
ya... but it worked in my Windows com. I am using dev-c++ in my windows com and it worked like a charm but i cant do it in geany...

phantomgunex
November 10th, 2008, 05:06 AM
hmmm... anyone know any GOOD IDEs??? i wanna try them... Oh ya is there a way to install dev-c++ for linux.

LaRoza
November 10th, 2008, 07:37 AM
hmmm... anyone know any GOOD IDEs??? i wanna try them... Oh ya is there a way to install dev-c++ for linux.

No, there is no such thing as a good ide. See the stickies ;)

Dev C++ uses the windows port of gcc. You can actually use that to compile directly.

I suggest you learn how to use gcc and g++ with any editor.

samjh
November 10th, 2008, 08:41 AM
As LaRoza said, just use an editor and the gcc and g++ compilers from the command line.

IDEs are quite distracting when learning a new language.

Geany is actually a very nice code editor, and can even be used as a very basic IDE.