Hi guys:
I created this program that will read into two files and compare a number from one file into the other and if they match, it will print out some information. I ave two if statements and it seems that the second one can't be read. I tried putting them in the same part but none are read. I know I need to fix my if statement, any ideas where ?
Thanks
Gus
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main()
{
char fileToRead[20];
char fileForTFR[20];
char cmpFile[20];
int numberImages, starsTFR;
cout << "Enter name of tfr file(e.g. daom_iiv1.tfr): ";
cin >> fileToRead;
cout << "Enter name for output file (e.g. list_tfr.comp): ";
cin >> fileForTFR;
cout << "Enter name of cmp file to be read (e.g. se3tose1.cmp) ";
cin >> cmpFile;
cout << "How many companion stars in file: ";
cin >> numberImages;
cout << "How many stars in TFR file: ";
cin >> starsTFR;
ifstream in1, in2;
in1.open(fileToRead);
in2.open(cmpFile);
ofstream out(fileForTFR);
double xc, yc,cxc,cyx,cidc2,cxc2,cyxc2 ;
vector<double> idc(starsTFR);
vector<double> idil(starsTFR);
vector<double> idis(starsTFR);
vector<double> idv(starsTFR);
vector<double> cidc(numberImages);
for(int j=0;j<starsTFR;j++ )
{
for (int i=0;i<numberImages;i++)
{
if (in1 >>idc[j]>>xc>>yc>>idil[j]>>idis[j]>>idv[j] && in2 >>cidc[i],cxc,cyx,cidc2,cxc2,cyxc2)
{
out <<idc[j] << endl;
// for(int i=0;i<numberImages;i++)
// {
// if (in2 >>cidc[i],cxc,cyx,cidc2,cxc2,cyxc2)
// {[CODE][/CODE]
out <<cidc[i];
if (idc[j]==cidc[i])
{
out << cidc[i] << " " << idil[j] << " " << idis[j] << " " << idv[j] << " " << idc[j] << endl;
}
// }
// }
}
}
}
out << endl;
return 0;
}
tfr file
1 333.497 288.780 1 1 1
2 -40.218 324.683 4 4 4
3 453.943 539.927 3 3 6
4 10.354 584.221 8 8 2
5 358.160 589.220 2 2 15
6 630.655 766.242 10 10 3
7 666.667 124.235 6 6 5
8 439.938 920.690 5 5 8
9 689.891 874.437 7 7 9
10 506.154 1000.178 9 9 23
11 617.505 631.415 13 12 12
12 459.831 914.150 25 29 7
13 569.784 778.539 14 16 42
14 435.473 849.193 22 26 19
cmp file
10 506.15 1000.18 9 506.12 1000.14
13 569.78 778.54 15 569.75 778.51
14 435.47 849.19 16 435.45 849.19
16 168.07 999.13 19 168.07 999.13
22 608.81 1063.53 26 608.75 1063.48
23 95.55 551.93 29 95.57 551.94