C++#include "stdafx.h"

好久没写C++程序了,碰到了很多问题。伤心中,加油,一点一点慢慢来,重拾的过程,理解能力还是不错的,呵呵,自我安慰 一下。


以前在VC6中写的简单的单文件的C++单文件程序中没注意到"stdafx.h"这个文件,先把它拿来看一看:

1、当我们建立一个空工程时,当然你里面是什么文件都没有的

2、当我们建立一个“hello world”工程是,出现了两个不速之客

         

         这个程序可以运行,看我们的主函数:

// del1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	printf("Hello World!\n");
	return 0;
}

我们没有看到有“error C2065: 'printf' : undeclared identifier”的错误产生,看来stdio.h这个头文件已经编译到本工程中了,那么,他在哪儿呢?

//StdAfx.cpp文件

// stdafx.cpp : source file that includes just the standard includes
//	del1.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

//---------------------------------------------------------------------------------------------

//StdAfx.h文件:


// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__8B8838C4_046A_4930_B82A_68E89A686214__INCLUDED_)
#define AFX_STDAFX_H__8B8838C4_046A_4930_B82A_68E89A686214__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers

#include <stdio.h>                      //<<<--------------------------------------------------------看这里

// TODO: reference additional headers your program requires here

//{
  {AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__8B8838C4_046A_4930_B82A_68E89A686214__INCLUDED_)

果然,他被包含在StdAfx.h了。

3、我们再建立一个空的MFC工程:

       

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值