0

I want to write a script (Windows 10) which will be testing my program. I have not found any suitable answer so I decided to open my own question.

I have files with input and output for my program eq.:

stud1.txt and stud1_out.txt alternatively.

My C++ program reads input from console (std::cin).

I know how to compare files (FC command) and how to run program from command line, but I have no idea how to pass on input data to a program which reads data using std::cin and then write it into the file to be able use FC command.

Thanks for any help :)

javier-sanz
  • 2,504
  • 23
  • 23
pjdev
  • 69
  • 2
  • 9
  • 2
    Possible duplicate of [Faking standard input on the Windows command line](http://stackoverflow.com/questions/15994824/faking-standard-input-on-the-windows-command-line) – Jonas Apr 18 '17 at 11:11

1 Answers1

0

Use < to pass file contents to the STDIN of a console program, e.g.:

console_prog.exe <input.txt

More details: Using command redirection operators

Dmitry Egorov
  • 9,542
  • 3
  • 22
  • 40