Given a set of data (two columns of data, flight path angles and lift coefficients) in a separate file, I need to write a program so the user can input a flight path angle and the program will return the appropriate lift coefficient given (if their angle matches one in the set) or interpolate the two closest values if their input is between two given angles. The compiler is telling me that i have error C2447: missing function header (old-style formal list?) up near the top, and fatal error C1004: unexpected end of file found near the bottom. Some help??
FPAngle= the angles given in the file. LiftCoef= coefficients given in the file, Angle= user input angle, LCoef=interpolated coefficient

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
 
void interpolate(double FPAngle, double LiftCoef, double Angle, double LCoef); 
{
{
LCoef = LiftCoef[i-1]+((Angle-FPAngle[i-1])*(LiftCoef[i]-LiftCoef[i-1])/(FPAngle[i]-FPAngle[i-1]));
return; 
}
 
int main()
{
// declare;
ifstream CalcLift;
string filename;
double FPAngle[17];
double LiftCoef[17];
double Angle;
double LCoef;
int i;
 
 
// Get data file
cout << "Enter data filename: ";
cin >> filename;
CalcLift.open(filename.c_str());
if(CalcLift.fail())
{
cout << "Error opening input file\n";
 
}
else
{
for (i=0; i<17; i++);
{
CalcLift >> FPAngle[i] >> LiftCoef[i];
 
cin >> "Enter flight path angle: ";
cin >> Angle;
}
for(Angle == FPAngle[i])
{
cout << LiftCoef[i];
}
 
 
for (Angle=-4; Angle < FPAngle[i]; Angle++);
{
interpolate (FPAngle[i], FPAngle[i-1], LiftCoef[i], LiftCoef[i-1]);
cout << LCoef;
}
CalcLift.close();
 
return 0;
}

Thanks for the help...i dunno, I tried doing that but i'd make sure they're even and i'd still get the same errors...talk about frustrating.

One problem is a mismatch between the left and right parentheses pairs. that is what C1004: unexpected end of file found near the bottom is most likely all about. (you are probably missing a rt parentheses)

From the code I see that might cure your other problem too.
good luck
huffstat


Given a set of data (two columns of data, flight path angles and lift coefficients) in a separate file, I need to write a program so the user can input a flight path angle and the program will return the appropriate lift coefficient given (if their angle matches one in the set) or interpolate the two closest values if their input is between two given angles. The compiler is telling me that i have error C2447: missing function header (old-style formal list?) up near the top, and fatal error C1004: unexpected end of file found near the bottom. Some help??
FPAngle= the angles given in the file. LiftCoef= coefficients given in the file, Angle= user input angle, LCoef=interpolated coefficient

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
 
void interpolate(double FPAngle, double LiftCoef, double Angle, double LCoef); 
{
{
LCoef = LiftCoef[i-1]+((Angle-FPAngle[i-1])*(LiftCoef[i]-LiftCoef[i-1])/(FPAngle[i]-FPAngle[i-1]));
return; 
}
 
int main()
{
// declare;
ifstream CalcLift;
string filename;
double FPAngle[17];
double LiftCoef[17];
double Angle;
double LCoef;
int i;
 
 
// Get data file
cout << "Enter data filename: ";
cin >> filename;
CalcLift.open(filename.c_str());
if(CalcLift.fail())
{
cout << "Error opening input file\n";
 
}
else
{
for (i=0; i<17; i++);
{
CalcLift >> FPAngle[i] >> LiftCoef[i];
 
cin >> "Enter flight path angle: ";
cin >> Angle;
}
for(Angle == FPAngle[i])
{
cout << LiftCoef[i];
}
 
 
for (Angle=-4; Angle < FPAngle[i]; Angle++);
{
interpolate (FPAngle[i], FPAngle[i-1], LiftCoef[i], LiftCoef[i-1]);
cout << LCoef;
}
CalcLift.close();
 
return 0;
}

1 move function definition to end of program.
and add a fn declaration before main()
compilers are fussy.

2 Try adding right parentheses to end of program.
then recompile. sometimes this error is hard to spot.

I do see an extra left parentheses in the function definition.

void interpolate(double FPAngle, double LiftCoef, double Angle, double LCoef); 
//<< LOOK, misplaced ;

{
{
LCoef = LiftCoef[i-1]+((Angle-FPAngle[i-1])*(LiftCoef[i]-LiftCoef[i-1])/(FPAngle[i]-FPAngle[i-1]));
return; 
} //<< LOOK - two open and one close
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.