I try to use a Python script in my C++ project in Visual Studio 2013. If I use the script one time, it works fine. But when I try to loop on it, I got this error message :
Access violation writing location 0x0000000000000002
And here is my code :
FILE *fd = fopen("somefile", "r");
for (;;) {
Py_Initialize();
PyObject* PyFileObject = PyFile_FromString("test.py", "r");
// file before returning:
PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), "test.py", 1);
Py_Finalize();
}
I think something is not closed but I can't find what is wrong. By the way, I'm using Python 2.7.