#include <iostream>
#include <fstream>
#include <string>
#include "LinDicT.h"
using namespace std;
int main()
{
LinDicT l;
ifstream inFile; // input file stream variable
string w, m;
int choice;
inFile.open("meanings.dat"); // open the input file
if (!inFile)
{
cout << "Cannot open the input file"
<< "The program terminates." << endl;
return 1;
}
while (!inFile.eof())
{
inFile >> w;
getline(inFile, m, '\n');
l.insert(w, m);
cout << "Enter your choice: " << endl;
cin >> choice;
if(choice == 1)
{
l.traverse();
}
else if(choice == 2)
{
List* def;
def = l.lookUp(w);
if(def == NULL)
{
cerr << "word not found!" << endl;
}
else
{
def->printList();
}
}
else if(choice == 3)
{
break;
}
}
inFile.close();
return 0;
}
When compiling it with other classes 'Segmentation Fault' occurs, can anyone spot an error in the above code please?
Thanks..