#include <Python.h>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]); /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
int x = 0;
cin >> x;
system("PAUSE");
return 0;
}
Any idea what's going on here? Oddly, when I place that code that's supposed to pause it
int x = 0;
cin >> x;
system("PAUSE");
in BEFORE all the python code, it does actually stop. Even worse: I've used breakpoints. If placed on or before the call to Py_Initialize(), the code stops at the breakpoint. Anywhere else, the breakpoint is never reached. Strangely, VC++ will usually tell you if a breakpoint will never be reached, however it seems to believe that the breakpoints placed after Py_Initialize() will be reached.
UPDATE::
So apparently there's an error occuring. I barely noticed it. What happens is, a message is output "Import Error: No module named site." The program then closes immediately. Any ideas? I'm googling now, and I'll be back with another update if I find an answer, for future readers.