致命错误:未找到“stdafx.h中”文件 [英] Fatal error: 'stdafx.h' file not found

查看:4391
本文介绍了致命错误:未找到“stdafx.h中”文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来编程的C ++,我试图通过我虽然已经停留在我编写的第一个程序的网站(learncpp.com)了解自己=(他们使用Visual Studio编写他们​​的code和因为我使用MacBook,我只是用vi和终端(或我应该使用别的东西吗?)

下面是我写的基础上的教程helloworld.cpp程序:

 的#includestdafx.h中
#包括LT&;&iostream的GT;
{
     性病::法院LT&;<!Hello World的<<的std :: END1;
     返回0;
}

当我编译(GCC -Wall HELLO.CPP)我得到的错误:

  helloworld.cpp:1:10:致命错误:stdafx.h中找不到文件的#includestdafx.h中
         ^
产生1个错误。

谁能给我见识到如何解决这一问题?


解决方案

  1. 的stdafx.h 是由Visual Studio使用的precompiled头,你并不需要这个。

  2. 您似乎已经错过了 INT的main()功能

  3. 的std :: ENDL 不是的std :: END1

因此​​,像这样:

 的#include<&iostream的GT;
诠释主(){
     性病::法院LT&;<!Hello World的<<的std :: ENDL;
     返回0;
}

I am new to programming C++ and am trying to learn myself through websites (learncpp.com) although I am already stuck on compiling my first program =( . They use Visual Studio to program their code and because I am using a macbook, I just use vi and terminal (or should I use something else?)

Here's the helloworld.cpp program I wrote based on the tutorial:

#include "stdafx.h"
#include <iostream>
{
     std::cout <<"Hello World!" <<std::end1;
     return 0;
}

when I compiled (gcc -Wall hello.cpp) I get the error :

helloworld.cpp:1:10: fatal error: 'stdafx.h' file not found

#include "stdafx.h"
         ^
1 error generated.

Can anyone give me insight on to how to fix this?

解决方案

  1. stdafx.h is the precompiled header used by visual studio, you do not need this.
  2. You seem to have missed out the int main() function
  3. It is std::endl not std::end1

So something like this:

#include <iostream>
int main() {
     std::cout <<"Hello World!" <<std::endl;
     return 0;
}

这篇关于致命错误:未找到“stdafx.h中”文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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