When I try to run my program it crashes right of the start. The problem is my input from file, I can write to the file fine. Can someone explain why this code wouldn't work??
StringList::StringList()
{
pTop=NULL;
pBottom=NULL;
ifstream in;
in.open("read.txt");
StringListNode * pCurrent;
pCurrent = new StringListNode;
pCurrent = pTop;
while(!in.eof()) //reads it till the end of file
{
in >> pCurrent->data;
pCurrent = pCurrent->pNext;
}
in.close();
}
This Output to the file works fine. I thought I would just include it.
StringList::~StringList()
{
ofstream out;
out.open("read.txt");
StringListNode * pCurrent;
pCurrent = new StringListNode;
pCurrent = pTop;
while(pCurrent != 0)
{
out << pCurrent->data << endl;
pCurrent = pCurrent->pNext;
}
out.close();
}