I am doing a project for school, and I am not looking for answers, more so just an explanation on what this error is and how to correct it.
The scenario of the project does not matter for me to explain (unless you feel otherwise), but the code block the error is reading is this:
void CallProcedure(string pName)
{
char* procname = new char[pName.length() + 1];
std::strcpy(procname, pName.c_str());
Py_Initialize();
PyObject* my_module = PyImport_ImportModule("PythonCode");
PyErr_Print();
PyObject* my_function = PyObject_GetAttrString(my_module, procname);
PyObject* my_result = PyObject_CallObject(my_function, NULL);
Py_Finalize();
delete[] procname;
}
The error occurs on line
PyObject* my_function = PyObject_GetAttrString(my_module, procname);
The error message is
Exception thrown at 0x1E0CB9E7 (python36.dll) in SetUp.exe: 0xC0000005:
Acess violation reading location 0x00000004."
I am very novice and very much a beginner so if I am missing something in regards of information I apologize.
I have tried googling this error and have not found a direct answer. I am merely trying to just run the code before I change anything to see what the output is in regard to what I need to change and where I am with the code provided to us in the project.