Jamie West Jamie West - 1 month ago 9
C Question

C program compilation error

I am new to programming and picked up the C language as my first computer language. I was doing a sample conversion program and when i compiled the code, i get the following error.

What does it mean and how do i fix it?

Thanks!

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


I am using VB 2010 as my IDE

Answer

The reason why you are experiencing a compile error is mentioned here:

error C2857: '#include' statement specified with the /YcStdAfx.h command-line option was not found in the source

This means that the compiler is making the inclusion of StdAfx.h compulsory. You can remedy this by adding #include <StdAfx.h> to your source code.