Sign-up....

为什么提示“stdafx.h"找不到

#include "stdafx.h"

int main (int argc,char* argv[])

{

putchar('C');

puchar('+');

putchar(43);

putchar('\n');

putchar('\n');

return 0;

}

用vc6编译,提示找不到stdafx.h。而且putchar()未定义。初学者,请赐教。这是个控制台程序

[224 byte] By [msdn] at [2007-10-1 16:51:01]
# 1 Re: 为什么提示“stdafx.h"找不到

你在DOS下编译?

lw1a2 at 2005-6-23 10:37:38 >
# 2 Re: 为什么提示“stdafx.h"找不到

不是,在win2000下

tools212 at 2005-6-23 10:42:10 >
# 3 Re: 为什么提示“stdafx.h"找不到

新建一个空的控制台工程,添加一个cpp文件,输入

#include <stdio.h>

int main (int argc,char* argv[])

{

putchar('C');

putchar('+');

putchar(43);

putchar('\n');

putchar('\n');

return 0;

}

lw1a2 at 2005-6-23 10:46:26 >
# 4 Re: 为什么提示“stdafx.h"找不到

用VC当然不能这样, 你用VC7.0编译就可以了

foochow at 2005-6-23 10:49:56 >
# 5 Re: 为什么提示“stdafx.h"找不到

#include "stdafx.h"

----

一般都用不着这个。。。

控制台程序用#include <stdio.h>就可以了。

mccxj at 2005-6-23 10:50:40 >
# 6 Re: 为什么提示“stdafx.h"找不到

用#include <stdio.h>,就提示putchar()未定义,我敲的是《c++高级参考手册》(Clayton Walnum 著)里面的代码,他的每一个程序都有这一句:#include "stdafx.h"。

tools212 at 2005-6-23 10:59:29 >
# 7 Re: 为什么提示“stdafx.h"找不到

stdafx.hstdafx.h是vc创建工程时自动生成的头文件,里面的内容一般是再包含其他的头文件,比如:

#include <stadlib.h>

#include <stadio.h>

universeboy at 2005-6-23 11:29:15 >
# 8 Re: 为什么提示“stdafx.h"找不到

以前偶也遇到过啼,嘿嘿偶在VC下找到这个stdafx.h直接来嵌入我的代码里。嘿嘿竟然成功罗

再也不提示什么找不到罗

www.50mi.net

fiftymetre at 2005-6-23 12:11:53 >
# 9 Re: 为什么提示“stdafx.h"找不到

这是VC的预编译头文件。其事你的控制台程序一般是不需要预编译头文件的。

启动工程的属性,取消预编译(预编译一般用于大型程序,可以大大提高编译速度)。

yhbttfile at 2005-6-23 22:11:49 >
# 10 Re: 为什么提示“stdafx.h"找不到

VC/MFC 版面应该就这个出个 FAQ 了。。。

Wolf0403 at 2005-6-23 22:16:18 >
# 11 Re: 为什么提示“stdafx.h"找不到

工程类型不对吧。Console里面不能包含stdafx.h。只有包含MFC的工程才需要这个文件。

aizhimin at 2005-6-23 22:49:44 >
# 12 Re: 为什么提示“stdafx.h"找不到

你用了console工程向导生成的程序还是单独自己写的一个文件?

bluedodo at 2005-6-24 17:00:37 >
# 13 Re: 为什么提示“stdafx.h"找不到

回复人: fiftymetre(www.50mi.net) ( ) 信誉:100 2005-06-23 12:11:00 得分: 0

以前偶也遇到过啼,嘿嘿偶在VC下找到这个stdafx.h直接来嵌入我的代码里。嘿嘿竟然成功罗

再也不提示什么找不到罗

------

天啦,我的独门武功也被你学了~~~

呵呵

levibathan at 2005-6-24 18:25:54 >

C/C++

All Classified