I have two data files, in which there are some data points with same values, I need to produce and output in which I'll only have the common data points.
Here's my code:
#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
int main()
{
long double p_1,pd_1, age, mag, p_2, pd_2, dm_2, tsc_2, s_2, d_2, lum_2;
double data1[1659];
double data2[1688];
std::ifstream fin ("sort.txt",std::ifstream::in);
std::ifstream gin ("sort1.txt", std::ifstream::in);
for(int i=0; i<1659; i++)
{
fin>> p_1 >> pd_1 >> age >> mag;
data1[i]= p_1;
}
for(int i=0; i<1688; i++)
{
gin>> p_2 >> pd_2 >> dm_2 >> tsc_2 >> s_2 >> d_2 >> lum_2;
data2[i]= p_2;
}
for(int i=0; i<1659; i++)
{
if(data1[i]==data2[i])
cout<<p_2<<"\t"<<pd_2<<"\t"<<dm_2<<"\t"<<tsc_2<<"\t"<<s_2<<"\t"<<d_2<<"\t"<<lum_2<<endl;
}
return(0);
}
I did not produce and output file as i wanted to see what my output looks like. Please help me out here.