I am reading in values from a file, and am not sure what's wrong with my code? My main issue is within the area in bold, can anyone tell me what's wrong?
Thanks.
Code: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; }


Reply With Quote

Bookmarks