I have been looking around the site for a similar answer and the closest I managed to find is this one. The answer gives the following C program for achieving this:
//My code file
#include <stdio.h>
#include <Python.h>
void main()
{
FILE* file;
int argc;
char * argv[3];
argc = 3;
argv[0] = "mypy.py";
argv[1] = "-m";
argv[2] = "/tmp/targets.list";
Py_SetProgramName(argv[0]);
Py_Initialize();
PySys_SetArgv(argc, argv);
file = fopen("mypy.py","r");
PyRun_SimpleFile(file, "mypy.py");
Py_Finalize();
return;
}
I would like to do something similar to this (using python 3, I don't know if that makes a difference) and generate an output using matplotlib
. However I don't know how to adapt this to a C++ program, especially given the types required by the functions (such as wchar_t**
for argv
). Is there a way to do this without having to perform various typecasts to C types?