I am trying to read a .dat file of 11 numbers, the code detects the time incrementation between them(this is an arbitrary value set in the .dat file). I am using while loop to process the other numbers in the fil, but when I use it, only the first value of the file appears on the graphics screen followed by zeros. my code is as follows:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
//int k;
double npts;
double time_inc;
//double sensor;
double seismicData;
//double new_double;
ifstream myFile;
ifstream fin;
//ifstream dataOutput;`
int main()
{
//this takes the data and analyses the number of points as well as the time incr.
ifstream fin("SEISMIC.dat", ios::in);
myFile.open("SEISMIC.dat");
fin >> npts;
cout << "Number of data points: " << npts;
fin >> time_inc;
cout << " Time incrementation:" << time_inc;
int num;
//myFile.open("SEISMIC.dat");
if (!myFile) {
cout << "Error: file could not be opened" << endl;
exit(1);
}
myFile >> num;
fin >> num;
//myFile >> seismicData;
while (!myFile.eof()) {
cout << "Next number is:" << num <<endl;
myFile >> num;
//cout << "Next number is:" << fin << endl;
//cout << seismicData << endl;
//myFile >> seismicData;
}
myFile.close();
}
I'm wondering if anyone could help me out. Attached is a screenshot of the .dat file