Sep 13, 2019 at 8:55pm UTC
I have a txt file added into the source files but the code isn't reading it. I am not getting any error messages.
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 38 39 40
#include <iostream>
#include <fstream>
#include <string>
#include "Classroom.h"
using namespace std;
Classroom myLib;
void loadDataset(string fileName)
{
ifstream myFile;
myFile.open(fileName.c_str());
}
void continueMessage(string message) {
cout << message << endl;
cout << "Press Enter to continue.." << endl; cin.get();
}
int main()
{
string fileName = "dataset.txt" ;
loadDataset(fileName);
myLib.print();
continueMessage;
string ID = "Janet Newman" ;
myLib.removeStudent (ID);
continueMessage("Janet Newman has been removed." );
//---------------------------------------------------------------------------
myLib.print();
continueMessage("All students are listed!" );
return 0;
}
Last edited on Sep 13, 2019 at 8:55pm UTC
Sep 13, 2019 at 9:34pm UTC
Okay......thanks for your "help".
Sep 13, 2019 at 9:41pm UTC
You need:
(a) Some lines of the form
myFile >>
etc.
in loadDataset() to read the contents of the file.
(b) Some means of returning the data you have then read within your Classroom object. Either a return value or an argument of the function loadDataset().
Last edited on Sep 13, 2019 at 9:49pm UTC