第一个程序出问题 [英] Problem with the first program

查看:81
本文介绍了第一个程序出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试开始一个新程序时,例如:

When I try to start a new program for example:

#include "stdafx.h"

#include< iostream>

int main()
{
std :: cout<< "Hello world and all that" <<的std :: ENDL;
返回0;
}

#include <iostream> int main() { std::cout<< "Hello world and all that" << std::endl; return 0; }

我遇到了问题:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>  Source.cpp
1>c:\users\lm\source.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'stdafx.h' or rebuild precompiled header
1>c:\users\lm\source.cpp(9): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>  ConsoleApplication1.cpp
1>c:\users\lm\consoleapplication1.cpp(4): warning C4627: '#include <iostrem>': skipped when looking for precompiled header use
1>          Add directive to 'stdafx.h' or rebuild precompiled header
1>c:\users\lm\consoleapplication1.cpp(13): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

推荐答案


当我尝试启动一个新程序时,例如:

When I try to start a new program for example:

#include <iostream>

int main()
{
    std::cout<< "Hello world and all that" << std::endl;
    return 0;
}

我遇到了问题:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>  Source.cpp
1>c:\users\lm\source.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'stdafx.h' or rebuild precompiled header
1>c:\users\lm\source.cpp(9): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>  ConsoleApplication1.cpp
1>c:\users\lm\consoleapplication1.cpp(4): warning C4627: '#include <iostrem>': skipped when looking for precompiled header use
1>          Add directive to 'stdafx.h' or rebuild precompiled header
1>c:\users\lmconsoleapplication1.cpp(13): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

由于您的项目使用的是预编译头文件,因此Source.cpp文件中包含的第一个头文件必须是"stdafx.h"。或"pch.h" (取决于使用的VS版本。) 

Since your project is using precompiled headers the very first header included in the Source.cpp file must be "stdafx.h" or "pch.h" (depends on VS version used). 

所以添加#include" stdafx.h"作为源文件中的第一行。

So add #include "stdafx.h" as the first line in the source file.


这篇关于第一个程序出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆