May 11, 2016 at 5:20am UTC
hello im trying to read from a text file. but does not open the file and does the else statement? does the location of the file matter? or is the format wrong?
1 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 31 32 33 34 35 36 37
/[code]void readFromFile()
{
int pIDIndex = 1;
int totalRunTimeTemp = 0;
//Task tempTask;
ifstream queueFile ("queue.txt" );
//queueFile.open("queue.txt");
while (!queueFile.eof())
{
if (queueFile.is_open())
{
Task tempTask;
tempTask.pID = pIDIndex;
pIDIndex++;
queueFile >> tempTask.initialPriority;
queueFile >> tempTask.totalRunTime;
tempTask.currentPriority = tempTask.initialPriority;
tempTask.remainingRunTime = tempTask.totalRunTime;
PriorityQueues[tempTask.initialPriority].push(tempTask);
cout << " it works" << endl;
}
else
cout << "plz check file" << endl;
}
queueFile.close();
}
Last edited on May 11, 2016 at 5:22am UTC
May 11, 2016 at 6:07am UTC
You have the queueFile.open command commented out. That's why the file is never opened.
May 11, 2016 at 2:18pm UTC
kurisutofaa lve tried that and thomas yea the file wont open.
May 11, 2016 at 3:12pm UTC
What was the error message?
May 11, 2016 at 3:25pm UTC
thomas it was a dumb mistake. when the program ran with would recreate a txt file and i would just rename it, instead of making a new one.