954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Java

Thanx for everyone's reply. I'm more and more being put off Java, although it looks like a good language in practise, the way it looks as a GUI doesn't appeal. Anyone know of a good free C++ IDE ? I have tried Devc++ from bloodshed, but it wont let me compile for some reason.

You may move this thread to C++ if you wish to keep things tidy :)

Thanks In Advance,
Matt

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

Sorry - looks like I pressed wrong button, I ment reply not new topic!

I apologise.

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

What error are you getting when you try to compile in Dev-C++? It's always worked fine for me.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

[Warning] In function 'int main()'

'cout' undeclared (first use this function}


And here is the code I am using to build Hi World proggy, testing Dev cpp :

#include
using namespace std;
int main()
{
cout << "Hello World From About\n";
}

I think the header maybe iostream , but when I try this I get about 150 (not kidding) errors, reporting on lines that excede the amount used ( 6 ).

Anyone help ?

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

When you have int main() it means that the function main() is returning a value of type int (an integer). Right after your cout statement you have to add a return (0); statement.

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

And yes, use iostream.h ... Sometimes Windows likes #include instead of iostream.h though!

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

It now says iostream not found and when iostream.h is tried, the same result.

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

Really? Hmm... what version of Dev-C++ are you using? The following works for me on Dev-C++ 4.0:

#include <iostream.h>

int main&#40;&#41; &#123; 
  cout << "Hello World From About\n";
  return 0;
&#125;
samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

The latest version of dev-cpp doesn't recognise , you need to use the standard version of the same header - . When you do, you need to qualify any entities from namespace std.

Here are two versions that do that, and should compile and run OK. If they don't, post back with your error messages.

#include <iostream>
using namespace std;
int main&#40;&#41;
&#123;
cout << "hello, world" << endl;
cin.get&#40;&#41;;
&#125;


or this:

#include <iostream>
int main&#40;&#41;
&#123;
std&#58;&#58;cout << "hello, world" << std&#58;&#58;endl;
std&#58;&#58;cin.get&#40;&#41;;
&#125;


Two things to note:

[1] The return statement is optional in main() (though some older compilers will complain)

[2] I added the cin.get() to stop your console window from disappearing before you've seen the output.

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

One more thing, there was an installation problem with a recent version of dev-cpp - it missed a path from the compiler options (which leads to hundreds of error message when you try to compile pretty much anything at all).

Go to:

Tools ~ Compiler Options ~ Directories ~ C++ Includes and check that it lists the paths for:

..\include
..\include\c++
..\include\c++\mingw32

It's the last one that you may have missing, if so, add it.

And don't be put off, there's really very little wrong with dev-cpp and I'm sure you'll get a lot of pleasure out of using it. Good value for money IMHO.

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

What do you mean by the latest version? The beta version? 5? I'm using 4 and the code I posted with "" works and has always worked for me.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

4.9.7.0

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

I'm downloading updates as I type... will post with result after!

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

Nope :

The top line of

#include
using namespace std;
int main()
{
cout << "hello, world" << endl;
cin.get();
}


is made all red and a load of errors appear like :
C:\Dev-Cpp\include\c++\iostream:44
bits/c++config.h: No such file or directory.


According to dev cpp, i'm using version 4.9.7.8 .

Any help will be appreciated, and I know this is a great program and I wanna use it :)

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

Have you checked the compiler options that I wrote about?

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

I am missing the last one, I was hoping the update may fix this. Any other ideas? I do have a copy of Metrowerks Codewarrior 5, but it's slightly different.

boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

Just add the last path to your compiler options and it should compile OK. The dev-cpp directory will be the same as for the others.

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

You star :P It's all working and hoo.exe ran :D but the window closed before I could see hello world :(.
Any line of code i should add to get a 'press any button to continue'?

Thank you ever so much, I am really looking forward to programming in C++ now, my first compiled language :D

#include <iostream> 
using namespace std; 
int main&#40;&#41; 
&#123; 
cout << "Hello World From About\n"; 
return &#40;0&#41;; 
&#125;
boohoo
Newbie Poster
11 posts since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

The answer is in the previous posts. Dev-c++ will close the console window as soon as the program terminates, so all you have to do is out in a command that stops it from terminating until you're ready. Simplest is just:

cin.get();

This will wait for you to press enter. In some instances you may want to add the following:

cin.ignore(1000,'\n');
cin.get();

Good luck!

Bob
Junior Poster
Team Colleague
129 posts since Feb 2003
Reputation Points: 15
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You