Hello World problems

Jul 16, 2008 at 8:06pm
Hello there,

I have recently started trying to learn C++ (as in today) and have been attempting the legendary hello world program. However i seem to be having little luck when trying to run the program. I will post the code i have below and the compiler i am using is called Dev-C++. I get an output messages after compiling which says

'Line = 32:2 File = C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h Message = #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.'

however i do not know how what this means so if anyone can help it will be greatly appreciated. this is my code below


#include <iostream.h>


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

Thankyou for any help
Darren Rutter
Jul 16, 2008 at 8:21pm
use #include <iostream> (remove the .h). Then below it use using namespace std; or you will have to change the cout to std::cout :)

In Dev-C++. You also want to add system("PAUSE"); before the return 0; to stop the console from closing immediately.
Jul 16, 2008 at 8:32pm
Hi there. thanks for your quick reply :). i have changed the file and it now looks as follows following what you have said:

#include <iostream>

int main()
{
std::cout << "Hello World!\n";
system("PAUSE");
return 0;
}

i get no output messages anymore but when i run the application i do not see the text 'Hello World' all i see is the phrase 'Press any key to continue . . .'

what do i need to do to be able to see the text i have written.
Many thanks.
Darren Rutter

Jul 16, 2008 at 8:38pm
When using cout everything is written to a buffer. You need to flush this buffer.

e.g.
cout << "Hello World!" << endl;
EndL = End Line and Flush Buffer.

otherwise.
1
2
cout << "Hello World!\n";
cout.flush();


Edit: The buffer will be flushed when fill, or you use a cin >>. In your cause it's flushed on the return 0; so it disappears before you see it :)
Last edited on Jul 16, 2008 at 8:39pm
Jul 18, 2008 at 7:35am
Man dev c++ is much much complex for a beginer

try to use turbo c++ v3.0(dos based but gui) or c-free v4.0
ur very own 1st prog will work

#include <iostream.h>


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

Zaita is making stuff more complex for u
Jul 18, 2008 at 11:04am
Good grief, eshwar, I've only been here three minutes and you've already spammed five threads.

Zaita is a professional developer and he knows what he is talking about. Can you really justify wasting time in someone's thread to tell him "forget language standards because they are too complex --use a seventeen year old piece of software instead"?
Jul 19, 2008 at 7:13am
Yeah! maybe you should try Turbo C++ 3.0...
this program works with turbo c:

1
2
3
4
5
6
7
8
9
10
11
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

cout<<"Hello World!";

getch();
}


this works if you are using an old compiler...
Last edited on Jul 22, 2008 at 12:01pm
Jul 21, 2008 at 3:21am
Insead of usingsystem("PAUSE"); can use cin.get();
Jul 21, 2008 at 3:47am
LOL. Nice one unattached!

@ gnt101 et. al.
For more on system("PAUSE") take a look at the thread stickied at the top of this forum titled Console Closing Down.
I never use pause anymore. (Of course, I tend to run everything from the command-line...) But that's me. ;-)
Jul 21, 2008 at 7:50pm
@eshwar: Dev-C++ is an ideal IDE for a beginner developer. I am not making it "complex" but merely pointing out the cause-and-solution to the OP's problems. iosteam.h is now depreciated, unfortunately you are using a 15yr+ old compiler. While this may work for you, it'd be hard for you to become a proficient C++ developer because you will be unable to use any of the standard 3rd party libraries (e.g. Boost. which large pieces of is going to be part of new C++ standard). If you cannot use Dev-C++; perhaps you should give up trying to be a developer.

@Duoas: I dunno what they are teaching kids these days =\ makes me cringe

Jul 22, 2008 at 4:29am
hi,

#include <iostream.h>

using namespace std; //Removes Explicit use of std::cout or std::endl...!!

int main()
{
cout << "Hello World" << endl;

return 0;
}

using namespace is good practice.. n if u write this line.. this will help u a lot..!!
Jul 22, 2008 at 8:08pm
@kunalnandi: Again, iostream.h is depreciated. You should be using <iostream> not <iostream.h>

Jul 23, 2008 at 3:01pm
zaita, duoas:

what do you think is the best compiler to use?

how bout other people in here?!

any suggestions?...
Last edited on Jul 23, 2008 at 3:02pm
Jul 23, 2008 at 3:27pm
closed account (z05DSL3A)
The best compiler/IDE is one that you can get on with.

At the moment I use Visual Studio Team System 2008, but that is because I am doing Windows development 99.9% of the time and don't have to worry about cross platform issues. For a free Windows only IDE I would recommend Visual C++ Express 2008.

After that look at Netbeans and Eclipse.
Jul 23, 2008 at 5:42pm
The best (read "most standard-compliant") compiler is, of course, gcc in any of its incarnations.
For Windows-only development, the best IDE is Visual Studio. For cross-platform, my previous choice was Dev-C++, but now that it's dead, a new champion has appeared: Code::Blocks.
KDevelop is good for Linux and I've heard Anjuta is also good.
Jul 23, 2008 at 8:01pm
@helios: There is no "best IDE".

Dev-C++ isn't "dead" so much as no longer developed. The support forums are still very busy, and there are many developers who are producing new DevPaks for it.

As Grey Wolf said, it's the one that you can get on with. Personally, I use Eclipse for both Windows and Linux development. I have previously used Visual Studio and Dev-C++.

I picked Eclipse because I can also use it for UML Modelling, PHP, Version Control, Database Design/Development. It's a multi-purpose framework. More than just an IDE.

For compiler. I use GCC (MingW is GCC port for Windows).
Jul 24, 2008 at 1:30pm
thanks guys for the replies...
really appreciate it..,
Jul 25, 2008 at 8:05pm
try this

#include <iostream.h>
#include<conio.h>

int main()
{
cout << "Hello World!\n";
getch();
return 0;

}

Jul 25, 2008 at 8:21pm
There's seem to be a problem here but what problem? I cant compile, run or built.
(screenshot) http://www.turboimagehost.com/p/558885/Screenshot.png.html

Thanks
Jul 26, 2008 at 3:35am
matanuragi,... else...?

im also having a problem with my 'hello world'...
the program looks like this:

1
2
3
4
5
6
7
8
9
// bcc1.cpp
#include <iostream>
using namespace std;

int main()
{
cout <<"Hello World from BCC 5.5\n";
cin.getch();
}



the compiler im using is borland c++ 5.5...
it gives me these errors:

Error E2209 bccl.cpp 2: Unable to open include file 'iostream'
Error E2282 bccl.cpp 3: Namespace name expected
Error E2451 bccl.cpp 7: Undefined symbol 'cout' in function main()
Error E2451 bccl.cpp 7: Undefined symbol 'endl' in function main()
*** 4 errors in Compile ***


could anyone tell me whats wrong with my codes...???
Last edited on Jul 26, 2008 at 3:43am
Topic archived. No new replies allowed.