Question about File Reader Class
Mar 31, 2013 at 11:09pm UTC
I am making a file reader class to read files. It must be able to ,given a string skip ahead to the line after the given string. I am trying to do this in the constructor. Here is the code I have:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #include "../inc/SnakeFileReader.hpp"
SnakeFileReader::SnakeFileReader(std::string& filePath, std::string& startString)
while (toFind != startString && !fileToRead_.eof())
fileToRead_ >> toFind;
std::string fileLine = "";
fileToRead_ >> fileLine;
The first constructor works fine. However the second caused a run time error when it tries to open the file (the same one given to the other constructor). I will put a check to make sure it can load a file but I still need to fix this.
Mar 31, 2013 at 11:28pm UTC
Just realised its not when it tries to open the file it causes the error (Segmentation Fault) its as soon as it enters the constructor.
Topic archived. No new replies allowed.