So I believe I managed to get the input to work using this code in Python:
p = Popen(['g++', 'a.out'], shell=True, stdout=PIPE, stdin=PIPE)
frp=open("cpp_input.txt", "r")
value=frp.read()
value = bytes(value, 'UTF-8')
p.stdin.write(value)
p.stdin.flush()
result = p.stdout.readline().strip()
return result
This is the C++ code I am running:
#include <iostream>
int main() {
char a, b, c; std::cin >> a >> b >> c;
std::cout << "Hello, world!";
return 0;
}
The input is (literally these three characters):
I printed out the input the code was using while debugging, and it was correct. So I know that the input file is correct and contains "N/A".
The C++ output is now blank; there is no error - but it didn't output "Hello, world!". Thank you in advance.