I caot figure out why I'm getting the error Segmentation fault: 11
Here is my code:
int main()
{
ifstream inFile;
inFile.open("myfile.txt", ifstream::in);
cin.rdbuf(inFile.rdbuf());
while(cin.good())
{
Expression* expression;
char paren, comma;
cin >> paren;
expression = SubExpression::parse();
cin >> comma;
parseAssignments();
cout << "Value = " << expression->evaluate() << endl;
symbolTable.clear();
}
inFile.close();
retu 0;
}
If I modify the code and create a counter that forces the loop to break on the last line I don't get the Segmentation fault: 11 message.
int main()
{
ifstream inFile;
inFile.open("input.txt", ifstream::in);
cin.rdbuf(inFile.rdbuf());
int counter = 0;
while(cin.good())
{
Expression* expression;
char paren, comma;
cin >> paren;
expression = SubExpression::parse();
cin >> comma;
parseAssignments();
cout << "Value = " << expression->evaluate() << endl;
symbolTable.clear();
counter++;
if(counter == 14)
break;
}
inFile.close();
retu 0;
}
