运行“hello world”的C ++错误,vs2010

时间:2015-02-21 05:46:19

标签: c++ visual-studio-2010

#include <iostream>
using namespace std;

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

我正在尝试在vs2010中运行这个最简单的代码,但在编译时我收到了100多个错误。

f:\vs2010\vc\include\fstream(14): error C2143: syntax error : missing ';' before '*' 

f:\vs2010\vc\include\fstream(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

f:\vs2010\vc\include\fstream(16): error C2653: 'ios_base' : is not a class or namespace name

f:\vs2010\vc\include\fstream(16): error C2061: syntax error : identifier 'openmode'

f:\vs2010\vc\include\fstream(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

这些错误。我该怎么办?

1 个答案:

答案 0 :(得分:-2)

尝试在您的代码中包含此实验

#include "stdafx.h"