How to fix Debug Assertion Failed error with buffer != nullptr when using muparser in Visual Studio with C++?

159 views Asked by At

I am developing a C++ program using Visual Studio, and the muparser library to evaluate a mathematical expression. However, when I run my code, I get the following error message:

Debug Assection Failed Image

This is the code I'm using:

#include <iostream>
#include "muparser.h"

int main(int argc, char* argv[])
{
    try
    {
        double var_a = 1;
        mu::Parser p;

        p.SetExpr("2*2");

        std::cout << p.Eval() << std::endl;
    }
    catch (mu::Parser::exception_type& e)
    {
        std::cout << e.GetMsg() << std::endl;
    }

    return 0;
}
0

There are 0 answers