Visual C++ "Hello World" problem

I am trying to get started learning C++ but for some reason this doesn't work;

#include <iostream>
using namespace std;

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

That is the code I have in Visual C++ Express Edition, it says 'there are build errors'. What have I done wrong?
this's impossible...
try this:

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


ps: whats the version of your visual c++?
Should be the latest version. I got it a couple days ago from the official Microsoft site.
Still not working.... am I supposed to do "Build (ProgramName)" or "Start Debugging. Both don't work. I can't see WHY!?
i use dev-c++.. maybe you can use it as a temporary compiler because it is small and free.
you can get it esaily..now i also want to get a visual studio express.. and i can see what to do by the way. if you use dev-c++, you need to add "system("pause");" at the end of main(), but before "return 0;"

ps: welcome to c++, work hard together..
Hey Duckwit

Can you post the errors you're getting?

That code should work fine, which leads me to believe that maybe your linker settings are not set properly, or you're not building the program as a console project.

i use dev-c++.. maybe you can use it as a temporary compiler because it is small and free.
you can get it esaily..now i also want to get a visual studio express.. and i can see what to do by the way. if you use dev-c++, you need to add "system("pause");" at the end of main(), but before "return 0;"

ps: welcome to c++, work hard together..


I wouldn't recommend using Dev-C++ anymore as it's no longer being updated. You should use wxDev-C++ instead.
thats why i want to use visual studio express now. and i really want to help Duckwit cuz the poor he is! he got a problem when he just stepped in c++, hey c++ go easy on us.

or you're not building the program as a console project.

this is just what on my mind.
It was not a console Application. :l Being a noob to the subject I just didn't know.... I figured the first type of C++ thing you could create was the normal one, so I clicked "Class Library". I feel....like a newbie.
Am I supposed to use CLR Console Application or Windows Forms Application?
I think the syntax for Visual C++ is different to the one taught here... this is what is there when you start a new program;

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
return 0;
}
dude your in the wrong path.. CLR means common language runtime.. that mean it's C++/CLI, that mean it runs on .NET frameworks. that's different from C++

for your code to work choose
1. new project
2. choose win32
3. win32 console application
4. click next then check "empty project"
5. click finish..

~hope that helps
Yes! Thank you. Now, when I want to start writing code which section do I want to do it in?
Header Files
Source Files
Resource Files

I am definitely a noob to the subject, but once I get started it should be easier...err...better.
Thanks! That is a video from 2008 though. It shows the "Hello World" working. Though when I insert the _exact_ code it opens then closes instantly. What is the code line for that not to happen? [Other than system("pause");]


You can also just use "Start Without Debugging" for now. It will automatically pause for a key press before it closes the console window.
Topic archived. No new replies allowed.