C++ Segfault Error - Out of ideas!?

I'm working on a c++ code project which requires the ability to read 1 file & write another simultaniously. I have created a class File (not the actual name but who cares) that contains 1 ofstream object & 1 ifstream object. My class handles the classes by ensuring the good() & is_open() functions returns true... show more I'm working on a c++ code project which requires the ability to read 1 file & write another simultaniously. I have created a class File (not the actual name but who cares) that contains 1 ofstream object & 1 ifstream object. My class handles the classes by ensuring the good() & is_open() functions returns true before any operations occur. The ofstream object works flawlessly when i tested it. The ifstream however keeps raising a segmentation fault when i try 2 read the file. Any ideas? Please & thank you. Here's the function for getting code with the ifstream object:

char getline (unsigned int length = 100000, char delim = '\n')
{
if (file.good() && file.is_open())
{
preline = file.tellg();
char* TempString;
file.getline(TempString, length, delim);
line = file.tellg();
return *TempString;
}
else throw ConnectionError;
}
1 answer