I want to check if some C++ programs are running correct or not. The programs are similar, take single or multiple inputs from user and print out the output. To automate this, I compile a program and provide the input from file(windows cmd):
a.out < input.txt > output.txt
However, in the output, the End line or even the input is not printed. Example:
cout<<"Enter a number: ";
cin>>a;
cout<<"You entered: "<<a;
I create the input file and just write 4 in it. Then the output is:
Enter a number: You entered: 4
How do I make the program to output properly. I tried saving the input.txt after pressing "Enter", saving 4\n in the file and also tried piping: more input.txt | a.out > output.txt. But these didn't work. I don't want to modify the C++ program code and was wondering if there was a way to achieve this by the way we run the program or by changing input format.