Advertisement

PLZ HELP!!!

Started by August 06, 2002 10:24 PM
45 comments, last by d2king10 22 years, 4 months ago
ok, i just started programing C++ and im readin "sams 21 days book" and im on the Hello world, well im using DEV-CPP and i input EXACTLY wat it says in book, and i get a error message every time, wat am i doing wrong...heres wat im puting in: #include <iostream> int main() { std::cout << "hello world!\n"; return 0; } plz help, thx [edited by - d2king10 on August 6, 2002 11:39:54 PM] [edited by - d2king10 on August 6, 2002 12:42:01 AM]
Ummm... try taking away the ''std::'' from infront of the ''cout'' and it should work fine. :D

-JtM
-JtM
Advertisement
nope, it says "Cant run program" =(
You could get that prob with DEV-CPP if you haven''t saved the source file. Try creating a new project and saving it before compiling and then trying to put in your code...

-JtM
-JtM
nope, not working...heres a ss



http://imagehost.auctionwatch.com/bin/imageserver.x/00000000/dragonslay3rboy/problem.JPG



[edited by - d2king10 on August 6, 2002 12:10:28 AM]
Changing the #include to:

#include <iostream.h>

should fix it.



I''''m a man with a one-track mind/
So much to do in one lifetime

Kam
I''m a man with a one-track mind/So much to do in one lifetimeKam
Advertisement
nope, doesnt work. it says source file not compiled, so i compile it but it says cant run program file.
Odd.. I admit I know nothing about DEV, but I ran the exact same proggy under Visual and got output (after adding the .h and removing the std::, of course) while leaving either in resulted in errors. Any DEV ppl out there?

I''''m a man with a one-track mind/
So much to do in one lifetime

Kam
I''m a man with a one-track mind/So much to do in one lifetimeKam
First of all, leave the program how it was in the original post. The .h is missing because thats the way C++ works. C uses the .h extension, and you can have it in there in C++, but only because all C++ compilers also do C, and so it understands what you mean. But in a C++ project, it doesn''t belong. Next, the std:: should also be there. This is also part of the ANSI/ISO C++ standard. It means that you are using the cout funtion from the std namespace. If you put at the top of the file "using namespace std" then you can leave out the std, because the compiler will check that namespace first for functions called (or something like that).

The reason all this works in VC++ if you add in the .h and leave out the std:: is because it is an absolutely terrible compiler for programming using strict ANSI/ISO standards. I don''t even think that VC.net is fully complient with the standard. Sad really. Although it is the one I use...

As to what your problem is d2king10: try making a new project and making sure it''s a console application. Win32 apps look for winmain. Console apps are more like DOS programs. I''ve even double checked to make sure that it compiles right in Dev-C++ (which it does). There is nothing there that should give you any problems as long as it''s a console app. Hope that clears things up a bit.

--Buzzy
(formerly buzzy_b)
And I think you need to add #include"cstdlib" then put:
system("pause"); before return 0;
then it should work.

.lick

This topic is closed to new replies.

Advertisement