Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to write a program in Python which takes a C program as input, executes it against the test cases which are also as inputs and print the output for each test case. I am using Windows.
Posted

1 solution

Please see:
https://docs.python.org/2/library/subprocess.html[^],
http://stackoverflow.com/questions/880918/how-to-redirect-the-output-of-exe-to-a-file-in-python[^].

However, starting and using of external process, in most cases, is a pretty bad, very limited approach. You get almost no control over the spawn process, so this approach is mostly limited to console-only application taking input from a command line and putting the output in a standard console, or some files. Much better approach would be using the library (DLL) by a Python application. How to do it depends on the particular Python implementation; some provide interoperability with native DLLs, some work with .NET assemblies…

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900