This tutorial or 'app note' will demonstrate how to run python3 from C
This tutorial expects you to understand basic C and Python3.
char buffer[100]; sprintf(buffer, "python3 hello.py"); puts("starting python3 in C"); system(buffer);
#include <stdio.h> #include <stdlib.h> int main(){ char buffer[100]; sprintf(buffer, "python3 hello.py"); puts("starting python3 in C"); system(buffer); // Runs command in bash; Stops C from executing puts("resuming C"); return 0; }
from os import system import sys import time if __name__ == "__main__": print("starting python") time.sleep(2);# Sleep for 2 seconds print("leaving python")