خرید بک لینک

Vote count: 0

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;
}

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 اسفند 1394 ساعت: 4:31

صفحه بندی