C程序编译错误

时间:2012-07-25 08:49:05

标签: c visual-studio-2010

我是编程新手,并将C语言作为我的第一个计算机语言。我正在做一个示例转换程序,当我编译代码时,我收到以下错误。

这是什么意思,我该如何解决?

谢谢!

1>------ Build started: Project: ConversionProgram, Configuration: Debug Win32 ------
1>Build started 24-07-2012 20:58:37.

1>InitializeBuildStatus:

1> Touching "Debug\ExcerciseProgram1.unsuccessfulbuild".
1>ClCompile:
1> conversion.cpp
1>c:\my documents\visual studio 2010\projects\excerciseprogram1\excerciseprogram1\question2.cpp(12): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\my documents\visual studio 2010\projects\excerciseprogram1\excerciseprogram1\question2.cpp(18): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>c:\my documents\visual studio 2010\projects\excerciseprogram1\excerciseprogram1\question2.cpp(32): error C2857: '#include' statement specified with the /YcStdAfx.h command-line option was not found in the source file
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.1

我使用VB 2010作为我的IDE

2 个答案:

答案 0 :(得分:8)

这里提到了您遇到编译错误的原因:

  

错误C2857:在源代码中找不到使用/YcStdAfx.h命令行选项指定的'#include'语句

这意味着编译器正在强制包含StdAfx.h。您可以通过在源代码中添加#include <StdAfx.h>来解决此问题。

答案 1 :(得分:6)

您的源文件似乎不包含预编译的头文件。如果您使用预编译的标头,则所有源文件必须包含"stdafx.h"作为第一个非注释。