In the preceding C code (fprintf()) is being used to access Python. As this isn't a C programming book, I won't provide the in-depth workings of the code, but here is a brief rundown of what is happening:
- Python is being imported into the code as a header file.
- The C code is told about the paths to Python runtime libraries.
- The Python interpreter is initialized.
- A Python script is hard-coded into the C code and processed.
- The Python interpreter is shut down.
- The C program finishes.
In real practice, the Python program to be executed would be pulled from a file, rather than being hard-coded, as it removes the need for the programmer to allocate memory and load the file contents.