I have a text file that I am trying to read several lines of data in from with ifstream so I can then add them to a linkedlist. I'm using a main class/function that my teacher provided me so I did not personally write any of it. I've written a few other classes to go along with it which I can provide if necessary, but when debugging, the issues start as soon as the main function starts to try and read in the data.
#include <iostream>
#include <fstream>
#include "datalogger.h"
using namespace std;
int main(int argc, char** argv) {
datalogger dl;
if (argc != 2) {
cout << "Usage: " << argv[0] << " <datafile>" << endl;
exit(0);
}
// Read the data
char* datafile = argv[1];
ifstream infile(datafile);
int timestamp;
double temperature;
double windspeed;
while (!infile.eof()) {
infile >> timestamp;
infile >> temperature;
infile >> windspeed;
if (!infile.eof()) {
dl.addData(timestamp, temperature, windspeed);
}
}
// Output the report
dl.printReport();
return(0);
}
The contents of the datafile
(smallerdata.txt) are as follows:
1480906168 -226 361
1480906168 -224 270
1480906175 -222 326
1480906179 -218 236
1480906187 -218 145
1480906189 -216 109
1480906189 -212 145
1480906190 -208 153
1480906197 -204 90
The timestamp
for the first line read in should be 1480906168 & the temperature
and windspeed
should be -226 & 361 respectively. Instead, my debugger is giving me these values while paused on breakpoints on lines 24-27:
timestamp = 0
temperature = 2.1219889530967339e-314
windspeed = 3.184022971431627e-314
Where the heck are these values coming from & why?