Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error During compilation of a C source code

I need help to identify the bug in my program that I have written in C. Please bear in mind that I am still learning C. I am trying to implement what I have learned to far. My IDE is MS visual studio 2010.

Here is the program, the program description is written as a comment:

/*The distance between two cities (in km) is input through the keyboard. 
Write a program to convert and print this distance in meters, feet, inches and centimeters*/

#include<stdio.h>
#include<conio.h>

//I have used #include<stdio.h> and #include<conio.h> above


int main()
{
float km, m, cm, ft, inch ;

clrscr();
printf("\nEnter the distance in Kilometers:");
scanf("%f", &km );

// conversions

m=km*1000;
cm=m*100;
inch=cm/2.54;
ft=inch/12;

// displaying the results

printf("\nDistance in meters =%f", m);
printf("\nDistance in centimeters =%f", cm);
printf("\nDistance in feet =%f", ft);
printf("\nDistance in inches = %f", inch);

printf("\n\n\n\n\n\n\nPress any key to exit the program.");
getchar();
return 0;
}

Errors:
1>e:\my documents\visual studio 2010\projects\distance.cpp(32): error C2857: '#include' statement specified with the /YcStdAfx.h command-line option was not found in the source file
like image 742
Plague Avatar asked Dec 16 '22 12:12

Plague


1 Answers

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

This means the compiler (VisualStudio 2010) is forcing the inclusion of StdAfx.h but in the source you are not including it.

Try adding:

#include <StdAfx.h>

at the top of your source file.

like image 180
Santiago Alessandri Avatar answered Dec 19 '22 01:12

Santiago Alessandri