Im writing a program to calulate the distance between two points unsing structures and functions. I have everthing working perfectly except that I cant get it to repeat for a second set of points. My input file has 10 points in it bit it stops after it reads the first two, can somebody please help me with this? here is what i have:
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
struct point
{
double X1, Y1, X2, Y2;
};
double distance( double X1, double Y1, double X2, double Y2 )
{
double d, t, u;
t = pow((X2-X1),2);
u = pow((Y2-Y1),2);
d = sqrt(t+u);
return(d);
}
void main(void)
{
point x;
double d;
ifstream inf("F://value.txt");
inf>>x.X1;
inf>>x.Y1;
inf>>x.X2;
inf>>x.Y2;
d = distance ( x.X1, x.Y1, x.X2, x.Y2 );
ofstream outf("F://distance.txt");
outf<<d;
}
thanks in advance for the help!