The following is a text file that has to be converted into three arrays dc[], gt[], and snr[]
the numbers for the gt array are in bold.
"This data file is arranged as follows
The number on a lone line is the dopant concentration in atoms/cucm x 1.00E-17
The next five lines are the gt in nanometers
followed by the signal to noise ratio in decibels 1.1
2 35.1
2.2 36.3
2.4 37.2
2.6 38.1
2.8 39.5 1.2
2 37.2
2.2 39.5
2.4 41.2
2.6 42.3
2.8 46.2 1.5
2 41.2
2.2 44.2
2.4 48.2
2.6 50.3
2.8 53.4 1.7
2 48.2
2.2 51.2
2.4 55.6
2.6 60.2
2.8 65.2 1.9
2 55.6
2.2 62.3
2.4 66.2
2.6 72.5
2.8 78.6
"
I understand that some sort of loop must be used in order to move all of the numbers above into three separate arrays, however the only way I can think of attempting to move it into the three separate arrays is as follows..
"
using namespace std;
#include<iostream>
#include<cmath>
#include<fstream>
#include<iomanip>
int main() {
char skiplines [210];
int i;
double dc[4], gt[25], snr[25];
ifstream indata("noisedata.txt");
for (i=0;i<4;i++)
{
indata.getline (skiplines, 210);
cout<<skiplines<<endl; //This has skipped up to line 5
}
for (i=4;i<=33;i++)
{
if (i==4);
indata>>dc[0];
cout<<dc[0];
if (i==10);
indata>>dc[1];
if (i==16);
indata>>dc[2];
if (i==22);
indata>>dc[3];
if (i==28);
indata>>dc[4];
if (i!=4||10||16||22||28);
indata>>gt[i]>>snr[i];
}
system("pause");
return 0;
}
"
If anyone could help me with figuring out how to input the numbers from the file into the three arrays that would be greatly appreciated.