when you run an ifstream in c++ and go into a textfile what is the data in the file converted to? this is my code
#include <iostream.h>
#include <fstream.h>
#include "TGraph.h"
#include <time.h>
#include "TDatime.h"
void deeznutz()
{
char inputFilename[] = "data.txt";
ifstream inFile;
int x;
inFile.open("data.txt", ios::in);
if (!inFile) {
cerr << "Can't open input file " << "data.txt" << endl;
exit(1);
}
const int MAX_SIZE = 20;
int day[MAX_SIZE];
int score[MAX_SIZE];
int numRecords = 0;
int iTemp = 1;
int iNew = 1;
while (iTemp)
{
iTemp = inFile >> day[numRecords];
iNew = inFile >> score[numRecords];
std::cout << "iTemp " << iTemp << std::endl;
std::cout << "iNew " << iNew << std::endl;
std::cout << "day: " << day[numRecords] << std::endl;
std::cout << "score: " << score[numRecords] << std::endl;
std::cout << std::endl;
iTemp = iTemp * iNew;
numRecords++;
}
in the code the integers are paired up, so 1 with 2, 3 with 4 and so on. with the odd ordered one being day and even being order it also displays information for iTemp and iNew. when i run it i get this kind of error:
*** Interpreter error recovered ***
root [1] .x deeznutz.C
iTemp 137142600
iNew 137142600
day: 1
score: 2
iTemp 137142600
iNew 137142600
day: 3
score: 4
iTemp 137142600
iNew 137142600
day: 5
score: 6
iTemp 137142600
iNew 137142600
day: 7
score: 8
iTemp 137142600
iNew 137142600
day: 9
score: 10
iTemp 137142600
iNew 137142600
day: 0
score: 4631464
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
iTemp 137142600
iNew 137142600
day: 0
score: 0
Error: Array index out of range day -> [21] valid upto day[19] deeznutz.C:37:
*** Interpreter error recovered ***
i don't undertand, why is it out of range and why for iTemp and iNew i get these weird files? the text flile looks like this:
1 2 3 4 5 6 7 8 9 10