Advertisement

Why does this hello world program not work?

Started by August 12, 2000 07:30 PM
5 comments, last by iceman00004 24 years, 4 months ago
Is there anything wrong with the following source code? #include int main() { cout << "Hello World!\n"; return 0; } I''m using a demo version of visual c++ and when I compile with it, it says there was a compiler error. I can''t seem to find out what the error was. What am I doing wrong?
firts of all make sure you are creatig a console application
and next time tell use what the compiler error is
we have seen enough errors to know exactly what they mean



"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Advertisement
try this:

#include
// need to include a header
int main()
{
cout << "Hello World!\n";
return 0;
}


Why Not?
lemme correct that fpr ZenGeneral:
        #include <iostream.h> // need to include a headerint main(){    cout << "Hello World!\n";    return 0;}        




- Pouya
#define PURE_STUPIDITY 128 PROGRAMMERS

Edited by - pouya on August 12, 2000 9:14:57 PM
If that is exactly how you typed everything, you forgot to specify which header file to include after #include. Try this:

    #include <iostream.h>int main(){cout << "Hello World!\n";return 0;}        


Oops, pouya beat me to it!

===========================================
As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality.

-Albert Einstein

Edited by - Tebriel on August 12, 2000 9:16:00 PM
I think you have to include iostream.h to use cin and cout. Try this:

#include

int main()
{
cout << "hello world!\n";
return(0);
}

And like ncsu121978 said make sure you set up your project as a win32 console application.

Hope that helps.
Advertisement
I made the anonymous entry above and after saying to include iostream.h I then went ahead and neglected to include it in my example code. What a dunce!

Tebrial and pouya beat me to the punch anyway.



Screw you guys! I''m going home.
--------------------------------Screw you guys! I'm going home.

This topic is closed to new replies.

Advertisement