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

Hello world program does not compile in visual 2010

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{

cout << "Hello World!";
cin.get();
return 0;


}

Compiles and runs in dev cpp and notepad ++ but not in visual, Im trying to teach myself witht he internet but have no idea why this wont work.

1>------ Build started: Project: Hello world.cpp, Configuration: Debug Win32 ------
1>  Hello world.cpp.cpp
1>c:\users\david\documents\visual studio 2010\projects\hello world.cpp\hello world.cpp\hello world.cpp.cpp(9): error C2065: 'cout' : undeclared identifier
1>c:\users\david\documents\visual studio 2010\projects\hello world.cpp\hello world.cpp\hello world.cpp.cpp(10): error C2065: 'cin' : undeclared identifier
1>c:\users\david\documents\visual studio 2010\projects\hello world.cpp\hello world.cpp\hello world.cpp.cpp(10): error C2228: left of '.get' must have class/struct/union
1>          type is ''unknown-type''
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
SlzzyDzzy
Newbie Poster
13 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

What type of project did you select? Make a new project with Win32 Console as the type.

Don't select empty project, and you can uncheck Precompiled Headers.

jonsca
Quantitative Phrenologist
Team Colleague
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
 

Ah, thats exactly it. I used an empty project.

SlzzyDzzy
Newbie Poster
13 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: