0

I have a python script that is called inside a C++ program. The python script creates a directory based on the current time, puts files in there, and then execution returns to C++. I want to save a parameters file into the directory created in the python program.

I figure my options are:

  1. Pass in the text to save in the parameters file to the Python program and have it create and save the file
  2. Return the location of the directory to C++ from python so it knows where to save the file
  3. Use C++ to locate the most recently created directory after execution of the python script and put file there

I'm not sure how to do any of this. My python script is not embedded. I use

    std::string test = "python analyzeData2.py";
system(test.c_str());

to call a python script.

Any ideas how to do this?

1 Answer 1

1

I'd go with option B -- return the location of the directory to c++ from python so it knows where to save the file.

If you plan on using system(), something like this:

char* dirname[64];
FILE* fin;

system("python analyzeData2.py > created.log");
fin = fopen("created.log", "r");
fgets(dirname, sizeof(dirname), fin);
fclose(fin);
/* dirname has contents of created.log */
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.