I have a C(on windows) program which has a main function which returns a value.
#include <stdio.h>
int testData()
{
int testErr = 0;
// ....
return(testErr);
}
int main(void) {
int mainErr = 0;
mainErr = testData();
printf("mainerr = %d", mainErr);
return mainErr;
}
This C code executable myTest.exe is run through python.
self.run_cmd = "myTest.exe "+cmd # pass agruments to the C exe
self.testRun = subprocess.run(self.run_cmd,
stdout=subprocess.PIPE, stdin=None, stderr=subprocess.PIPE,
bufsize=0, universal_newlines=True, timeout=100)
print(">>>>", self.testRun.stdout)
print(">>>>", self.testRun.stderr)
Using "print(">>>>", self.testRun.stdout)" I am not getting the C code's return value in python. In python how to get the return value returned by C main.