I'm creating a test script for a program that relies on user input. To start my program from my test file, I use
system("./calc")
This initializes the program as expected. So I tried to do the same with a few inputs.
system("1+1")
system("2+2")
etc...
However, what ends up happening is my program starts, but still waits for explicit user input from me. Its only when I quit out of my program that the subsequent system() calls execute. But of course, since the program ended, they mean nothing at that point.
Its clear that the first system() call waits for the program to finish executing before going to the next lines of the test program. How can I issue commands from a test script while the program is running?