Click here to Skip to main content
14,641,306 members
Rate this:
Please Sign up or sign in to 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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100