Программа вылетает после открытия файла [закрыто]
Мне нужно прочитать значения из файла в мою программу. Файл успешно открывается, но сразу вылетает. Что-то не так с моим кодом?
void createList(intNode*& intList)
{
intNode* lastInt; //points to last integer in file
lastInt = NULL;
int fileInt; //int read from input file
ifstream intInputFile;
intInputFile.open("intInput.txt");
if (intInputFile.is_open())
{
cout < "intInput.txt open successful" < endl;
}
else
{
cout < "intInput.txt open unsuccessful" < endl;
}
intInputFile >> fileInt;
while(!intInputFile.eof())
{
intNode* anotherInt;
anotherInt = new intNode;
if(intList==NULL)
{
intList = anotherInt;
lastInt = anotherInt;
}
else
{
lastInt->nextNode = anotherInt;
}
lastInt = lastInt->nextNode;
lastInt->intValue = fileInt;
lastInt->nextNode = NULL;
intInputFile >> fileInt;
}
intInputFile.close();
cout < "List created from input file" < endl;
}
fileInt;
Потому что сразу после этого у меня было заявление о том, чтот работа.
И после более подробного изучения проблема в этой строке:
intInputFile >> fileInt;