Я пробовал использовать Python.h:
Код: Выделить всё
#include
int python_program(char* cwd)
{
char* python_file_path;
FILE* fd;
int run;
python_file_path = malloc(sizeof(char) * (strlen(cwd) + strlen("src/query.py") + 1));
strcpy(python_file_path, cwd);
strcat(python_file_path, "src/query.py");
fd = fopen(python_file_path, "r");
Py_Initialize();
run = PyRun_AnyFile(fd, "query.py"); //this part is where the bug occur i think
Py_Finalize();
free(python_file_path);
}
int main(int argc, char *argv[])
{
char cwd_buffer[64];
getcwd(cwd_buffer, sizeof(cwd_buffer));
python_program(cwd_buffer);
return 0;
}
Код: Выделить всё
26057 segmentation fault (core dumped) ../spotify-viewer-cli
Подробнее здесь: https://stackoverflow.com/questions/792 ... -c-program
Мобильная версия