Suppose I have a simple C ++ program that takes input and prints some string. Like this (the actual program is much more complicated, but still based on the text):
$ ./game
$ what kind of game? type r for regular, s for special.
$ r
$ choose a number from 1 - 10
$ 1
$ no try again
$ 2
$ no try again
$ 5
$ yes you WIN!
I have not used Python before, but is it possible to write a python script to run this program, submit it to the input and output the results to standard output? I asked a question here about running it using C ++, but it seems too complicated. It would be great if you could direct me to some code examples. Any help would be appreciated.
source
share