Here's the relevant code. The whole project compiles with no issues.
list<Line> loadText(const string &textFile)
{
ifstream txt;
string temp;
char ch;
list<Line> fullText;
unsigned length;
txt.open(textFile.c_str());
if (!txt)
{
cout << "Can't open " << txtFile << " \n";
exit(1);
}
// process file line by line
txt.seekg (0, ios::end);
length = txt.tellg();
txt.seekg (0, ios::beg);
cout << length;
for(int j = 0; j < length; j++)
{
cout << j;
txt.get(ch);
temp += ch;
cout << ch;
if (ch == '\n')
{
cout << temp;
Line line(temp);
row.printLine();
fullText.push_back(row);
cout<< "line done \n";
}
}
So this function is meant to take a text file, and make an List of Lines(a custom class that stores a list of characters). All of the 'cout' is for debugging purposes.
If i input a text file like this:
Line 1
Line 2
Line 3
Line 4
I get an output like this:
loading maze...
30 0L1i2n3e4 516
Line 1
Line 1
line done
destroyed
Note that destroyed is just the output given when a Line
s destructor is called.
So obviously its having issue after the first iteration, but after hours of trying to sort this out, i haven't figured this out.